[软件开发] GIT 常用命令整理
作者:CC下载站 日期:2019-01-07 00:00:00 浏览:65 分类:编程开发
master : 默认开发分支; origin : 默认远程版本库
初始化操作
$ git config -global user.name <name> #设置提交者名字
$ git config -global user.email <email> #设置提交者邮箱
$ git config -global core.editor <editor> #设置默认文本编辑器
$ git config -global merge.tool <tool> #设置解决合并冲突时差异分析工具
$ git config -list #检查已有的配置信息
创建新版本库
$ git clone <url> #克隆远程版本库
$ git init #初始化本地版本库
修改和提交
$ git add . #添加所有改动过的文件
$ git add <file> #添加指定的文件
$ git mv <old> <new> #文件重命名
$ git rm <file> #删除文件
$ git rm -cached <file> #停止跟踪文件但不删除
$ git commit -m <file> #提交指定文件
$ git commit -m “commit message” #提交所有更新过的文件
$ git commit -amend #修改最后一次提交
$ git commit -C HEAD -a -amend #增补提交(不会产生新的提交历史纪录)
查看提交历史
$ git log #查看提交历史
$ git log -p <file> #查看指定文件的提交历史
$ git blame <file> #以列表方式查看指定文件的提交历史
$ gitk #查看当前分支历史纪录
$ gitk <branch> #查看某分支历史纪录
$ gitk --all #查看所有分支历史纪录
$ git branch -v #每个分支最后的提交
$ git status #查看当前状态
$ git diff #查看变更内容
撤消操作
$ git reset -hard HEAD #撤消工作目录中所有未提交文件的修改内容
$ git checkout HEAD <file1> <file2> #撤消指定的未提交文件的
修改内容
$ git checkout HEAD. #撤消所有文件
$ git revert <commit> #撤消指定的提交
分支与标签
$ git branch #显示所有本地分支
$ git checkout <branch/tagname> #切换到指定分支或标签
$ git branch <new-branch> #创建新分支
$ git branch -d <branch> #删除本地分支
$ git tag #列出所有本地标签
$ git tag <tagname> #基于最新提交创建标签
$ git tag -d <tagname> #删除标签
合并与衍合
$ git merge <branch> #合并指定分支到当前分支
$ git rebase <branch> #衍合指定分支到当前分支
远程操作
$ git remote -v #查看远程版本库信息
$ git remote show <remote> #查看指定远程版本库信息
$ git remote add <remote> <url> #添加远程版本库
$ git fetch <remote> #从远程库获取代码
$ git pull <remote> <branch> #下载代码及快速合并
$ git push <remote> <branch> #上传代码及快速合并
$ git push <remote> : <branch>/<tagname> #删除### 远程分支或标签
$ git push -tags #上传所有标签
猜你还喜欢
- 03-29 [编程相关] Winform窗体圆角以及描边完美解决方案
- 03-29 [前端问题] has been blocked by CORS policy跨域问题解决
- 03-29 [编程相关] GitHub Actions 入门教程
- 03-29 [编程探讨] CSS Grid 网格布局教程
- 10-12 [编程相关] python实现文件夹所有文件编码从GBK转为UTF8
- 10-11 [编程算法] opencv之霍夫变换:圆
- 10-11 [编程算法] OpenCV Camshift算法+目标跟踪源码
- 10-11 [Python] python 创建 Telnet 客户端
- 10-11 [编程相关] Python 基于 Yolov8 + CPU 实现物体检测
- 03-15 [脚本工具] 使用go语言开发自动化脚本 - 一键定场、抢购、预约、捡漏
- 01-08 [编程技术] 秒杀面试官系列 - Redis zset底层是怎么实现的
- 01-05 [编程技术] 《Redis设计与实现》pdf
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[电影] 《变形金刚系列》七部合集 [4K HDR 蓝光] 国英双语音轨 [内封精品特效字幕]【典藏版】235G
[影视剧] 2024上半年熬夜必追的10部剧
[模拟经营] 模拟人生4豪华版/The Sims 4 Deluxe Edition
[模拟经营] 【沙威玛传奇】无广告版本+无限金币版本
[动作冒险] 侠盗猎车手5 MOD可剧情版/GTA5 MOD可剧情版/Grand Theft Auto V5
[游戏合集] 要战便战 v0.9.107 免安装绿色中文版
[有声小说] 《读心师》作者:向林 主播: 章鱼 53回完结
[有声小说] 《异悚》作者:黑色火种 演播:冰河 195集完结
[有声小说] 《盛华》作者:闲听落花 主播:姝姝 465集完结
[有声小说] 《修真聊天群》作者:圣骑士的传说 主播:云天河 3120集完结
[文件编辑] WinHex 21.2 SR-2_x86_x64 绿色单文件版
[图片浏览] 2345看图王去广告安装版 x86 x64 11.3.0.10165
[电影] 死侍与金刚狼 DeadPool.And.Wolverine.2024.V4.2160p [MP4]
[游戏] 《黑神话悟空》免安装学习版【全dlc整合完整版】+Steam游戏解锁+游戏修改工具!
[涨点姿势] 男性性技宝典:14招实战驭女术——爱抚、按摩、催情、姿势、高潮全攻略
[美剧] [黑袍纠察队 第四季][全8集][MKV][中文字幕][1080P]
[电视剧集] [BT下载][黑暗城市- 清扫魔 Dark City: The Cleaner 第一季][全06集][英语无字][MKV][720P/1080P][WEB-RAW]
[动画] 《名侦探柯南》名侦探柯南百万美元的五菱星 [TC] [MP4]
[短剧] 被下架·禁播的羞羞短剧·午夜短剧合集
[CG剧情] 《黑神话:悟空》158分钟CG完整剧情合集 4K120帧最高画质
[影视] 美国内战 4K蓝光原盘下载+高清MKV版/内战/帝国浩劫:美国内战(台)/美帝崩裂(港) 2024 Civil War 63.86G
[美剧] [黑袍纠察队 第四季][全8集][MKV][中文字幕][1080P]
[电影] 《黄飞鸿》全系列合集
[瓜] 恒大歌舞团被扒,意外暴露惊人内幕,难怪许家印商业帝国会崩盘
[Android] 开罗游戏 ▎像素风格的模拟经营的游戏厂商安卓游戏大合集
[游戏合集] 要战便战 v0.9.107 免安装绿色中文版
[资源] 精整2023年知识星球付费文合集136篇【PDF格式】
[文件编辑] WinHex 21.2 SR-2_x86_x64 绿色单文件版
[图片浏览] 2345看图王去广告安装版 x86 x64 11.3.0.10165
[美图] 【经典收藏美图集合】1500多张韩国美女高清图片让你的收藏夹更加丰富多彩
- 最新评论
-
找了好久的资源,终于在这里找到了。感谢本站的资源和分享。谢谢WillKwok 评论于:10-09 帖子里不是写着么【相关密码】:www.52sk2.comCC下载站 评论于:10-07 感谢分享1234123 评论于:10-07 百度网盘怎么还有个解压码啊,解压码是什么lrq2004042 评论于:10-07 太好了终于找到了谢谢Tom 评论于:10-07 谢谢分享loonghd 评论于:09-30 好多演員都出演過黃飛鴻,但還是李連杰最突出338 评论于:09-30 很喜欢,感谢分享1506098895 评论于:09-22 寻回童年回忆AnDemon 评论于:09-21 不错,不错剧毒 评论于:09-07
- 热门tag