100条git命令
-
1. git init:初始化一个新的git仓库
2. git clone [url]:克隆一个远程仓库到本地
3. git add [file]:将文件添加到暂存区
4. git commit -m [message]:提交暂存区中的文件到版本库
5. git status:查看文件的状态
6. git diff:查看文件的差异
7. git log:查看提交日志
8. git branch:查看分支列表
9. git checkout [branch]:切换到指定分支
10. git merge [branch]:将指定分支合并到当前分支
11. git remote -v:查看远程仓库的地址
12. git push [remote] [branch]:将本地分支推送到远程仓库
13. git pull [remote] [branch]:拉取远程仓库的更新
14. git stash:将当前的工作区保存到一个临时存储栈中
15. git stash list:查看存储栈中的工作区
16. git stash apply:恢复最近一次保存的工作区
17. git stash drop:删除最近一次保存的工作区
18. git stash pop:恢复并删除最近一次保存的工作区
19. git remote add [remote] [url]:添加一个远程仓库
20. git remote remove [remote]:移除一个远程仓库
21. git branch [branch]:创建一个新的分支
22. git branch -d [branch]:删除一个分支
23. git tag [tag]:给当前提交打一个标签
24. git tag -a [tag] -m [message]:给当前提交打一个带注释的标签
25. git tag -l:列出所有的标签
26. git tag -d [tag]:删除指定的标签
27. git reset [commit]:将HEAD指针指向指定的commit
28. git reset –hard [commit]:舍弃指定commit之后的所有修改
29. git revert [commit]:撤销指定commit的修改
30. git config –global user.name [name]:设置用户名
31. git config –global user.email [email]:设置用户邮箱
32. git config –global core.editor [editor]:设置默认的编辑器
33. git config –global color.ui true:开启命令行颜色显示
34. git config –global alias.[alias] [command]:设置命令别名
35. git rm [file]:从版本库中删除文件
36. git mv [old file] [new file]:移动或重命名文件
37. git branch -r:查看远程分支列表
38. git branch -vv:查看本地分支与远程分支的对应关系
39. git cherry-pick [commit]:选择一个指定commit并合并到当前分支
40. git rebase [branch]:将当前分支变基到指定分支
41. git remote show [remote]:查看远程仓库的详细信息
42. git reflog:查看HEAD的操作历史
43. git clean:删除未跟踪的文件
44. git revert -n [commit]:撤销指定commit的修改,但不产生新的commit
45. git bisect start:启动一个二分查找来定位引入错误的commit
46. git bisect good/bad:标记当前commit为好/坏
47. git bisect run [script]:在二分查找期间运行指定脚本
48. git show [commit]:显示指定commit的详细信息
49. git blame [file]:显示文件中每一行的提交信息
50. git remote prune [remote]:删除远程仓库中已经不存在的分支
51. git fsck:检查git仓库的完整性
52. git rebase -i [commit]:交互式地修改提交历史
53. git fetch [remote]:从远程仓库获取最新的修改,但不进行合并
54. git stash save [message]:保存当前的工作区,并提供一个描述性的message
55. git stash branch [branch]:从stash创建一个新的分支
56. git archive [commit]:将一个commit的内容打包为一个压缩文件
57. git checkout — [file]:恢复被修改的文件到最新的版本
58. git checkout -b [branch] [commit]:基于指定commit创建一个新的分支
59. git checkout [commit] — [file]:恢复指定commit中的文件到当前工作区
60. git rebase -i [branch]:交互式地修改指定分支的提交历史
61. git bisect reset:结束二分查找并重置到初始状态
62. git tag -a [tag] [commit]:给指定commit打标签
63. git tag -f [tag] [commit]:强制修改指定tag所指向的commit
64. git push [remote] :[branch]:删除远程仓库中的一个分支
65. git commit –amend:修改最新的commit的提交信息
66. git cherry-pick -x [commit]:选择一个commit并合并到当前分支,并保留原有的作者信息
67. git format-patch [commit]:为指定commit创建一个patch文件
68. git am [patch file]:应用一个patch文件
69. git stash drop [stash]:删除指定的stash
70. git revert –no-commit [commit]:撤销指定commit的修改,并暂存修改结果
71. git bisect visualize:以图形化的方式展示二分查找的结果
72. git clean -n:显示将要被删除的未跟踪文件
73. git remote set-url [remote] [url]:修改远程仓库的地址
74. git remote rename [old remote] [new remote]:重命名一个远程仓库
75. git reset –hard HEAD:回退到最新的提交
76. git reset –hard HEAD^:回退到上一个提交
77. git reset –hard HEAD~[n]:回退到前n个提交
78. git reset –hard [commit]:回退到指定commit
79. git remote prune origin –dry-run:查看执行git remote prune后将删除的分支
80. git bisect visualize –oneline:以一行的方式展示二分查找的结果
81. git commit –fixup [commit]:标记一个commit为修复某个commit引入的错误
82. git commit –squash [commit]:将一个commit合并到前一个commit
83. git diff [branch1] [branch2]:比较两个分支之间的差异
84. git blame -L [start],[end] [file]:只显示指定行范围的文件的提交信息
85. git remote prune origin:删除远程仓库中已经不存在的分支
86. git reflog expire –expire-unreachable=now –all:清理无法访问的commit
87. git branch -m [old branch] [new branch]:重命名一个分支
88. git rebase –continue:继续执行一个rebase操作
89. git rebase –skip:跳过当前commit的合并
90. git stash drop [stash]:删除指定的stash,并恢复工作区
91. git rebase –onto [newbase] [oldbase] [branch]:将一个分支的提交应用到新的base上
92. git tag –contains [commit]:查找包含指定commit的标签
93. git rev-parse –abbrev-ref [HEAD]:获取当前所在分支的名称
94. git blame -C -C -C [file]:显示文件中每一行的提交信息,同时跟踪重命名和拷贝
95. git cherry-pick — no-commit [commit1] [commit2]:选择多个commit并合并到当前分支,并暂存修改结果
96. git stash drop [stash1] [stash2]:删除指定的多个stash
97. git reflog –date=iso:以ISO 8601格式显示HEAD的操作历史
98. git remote prune [remote] –dry-run:查看执行git remote prune后将删除的远程分支
99. git branch -vv –no-merged [branch]:查看没有合并到指定分支的本地分支
100. git diff [commit1] [commit2] –stat:以统计图表的方式显示两个commit之间的差异2年前 -
1. git init:用于初始化一个新的仓库。
2. git clone [url]:用于克隆一个远程仓库到本地。
3. git add [file]:将文件添加到暂存区。
4. git status:显示当前仓库的状态。
5. git commit -m [message]:将暂存区的文件提交到仓库,并添加提交信息。
6. git push [remote] [branch]:将本地仓库的变更推送到远程仓库。
7. git pull [remote] [branch]:从远程仓库拉取最新的代码并合并到本地仓库。
8. git branch:显示当前所有的分支。
9. git checkout [branch]:切换到指定的分支。
10. git merge [branch]:将指定分支的代码合并到当前分支。
11. git remote add [name] [url]:添加一个远程仓库。
12. git remote -v:显示当前仓库的远程仓库列表。
13. git log:显示当前分支的提交历史。
14. git diff:显示当前分支的变更内容。
15. git stash:将当前分支的未提交的变更暂存起来。
16. git stash pop:恢复最近暂存的变更,并将其从暂存区中删除。
17. git tag [name]:给当前分支的最新提交添加一个标签。
18. git checkout [commit]:切换到指定的提交。
19. git revert [commit]:撤销指定的提交。
20. git reset [commit]:将当前分支的HEAD指针移动到指定的提交。
21. git fetch [remote]:从指定的远程仓库下载最新的代码,但不合并到当前分支。
22. git clean -f:清除未跟踪的文件。
23. git show [commit]:显示指定提交的详细信息。
24. git config –global [option]:配置全局git设置。
25. git rm [file]:将文件从版本控制中删除。
26. git blame [file]:显示指定文件的每一行是谁修改的。
27. git mv [file] [new name]:将文件重命名或移动到新位置。
28. git remote show [remote]:显示指定远程仓库的详细信息。
29. git reset –hard [commit]:将当前分支的HEAD指针移动到指定的提交,并丢弃所有未提交的变更。
30. git cherry-pick [commit]:将指定的提交应用到当前分支。
31. git rebase [branch]:将当前分支的变更应用到指定的分支上。
32. git config –list:显示git的配置信息。
33. git log –graph:以图形化的形式显示当前分支的提交历史。
34. git show-branch:显示所有分支的最后一个提交。
35. git reflog:显示所有的引用(包括分支和标签)。
36. git revert –no-commit [commit]:撤销指定的提交,并将撤销的变更添加到暂存区。
37. git grep [pattern]:在版本库中搜索指定的模式。
38. git bisect [good] [bad]:用于进行二分查找,找出引入错误的提交。
39. git diff [commit1] [commit2]:显示两个提交之间的差异。
40. git stash list:显示当前分支暂存区的列表。
41. git cherry-pick –abort:取消正在进行的cherry-pick操作。
42. git rev-parse –abbrev-ref HEAD:显示当前分支的名称。
43. git reset HEAD [file]:取消指定文件的暂存状态。
44. git remote remove [name]:删除指定名称的远程仓库。
45. git clean -n:显示将要被删除的未跟踪文件列表,但不删除。
46. git show-branch [branch]:显示指定分支的最后一个提交。
47. git checkout -b [branch]:创建并切换到一个新的分支。
48. git merge –abort:取消正在进行的合并操作。
49. git tag -a [tag] -m [message]:为指定的提交添加一个带有标签和消息的标签。
50. git log –follow [file]:显示指定文件的提交历史,包括其删除和重命名的情况。
51. git log –oneline:显示提交历史的简化版本。
52. git log –author=”[author]”:显示指定作者提交的历史。
53. git log –grep=”[pattern]”:显示提交消息中包含指定模式的历史。
54. git blame -L [start], [end] [file]:显示指定文件指定行代码的修改者。
55. git stash drop [stash]:删除指定的暂存区。
56. git push [remote] –tags:将本地仓库的所有标签推送到指定的远程仓库。
57. git rebase -i [commit]:交互式地将当前分支的变更重新应用到指定的提交之上。
58. git reset [file]:取消指定文件的修改。
59. git remote rename [old name] [new name]:将远程仓库的名称改为新的名称。
60. git blame -w [file]:显示指定文件的每一行是谁修改的,忽略空白的变更。
61. git rev-parse –show-toplevel:显示当前仓库的根目录路径。
62. git stash apply [stash]:将指定的暂存区恢复到当前分支,但不删除该暂存区。
63. git push –force:强制推送当前分支的变更到远程仓库。
64. git log –all:显示所有分支的提交历史。
65. git log –since=[date]:显示指定日期之后的提交历史。
66. git log –until=[date]:显示指定日期之前的提交历史。
67. git blame -M [file]:显示指定文件的每一行是谁修改的,同时还会显示文件重命名的情况。
68. git log –no-merges:显示提交历史中排除合并提交。
69. git revert –skip [commit]:跳过指定的提交并继续撤销后面的提交。
70. git diff [branch1] [branch2]:显示两个分支之间的差异。
71. git sparse-checkout init –cone:启用sparse-checkout模式,并只拉取指定目录下的文件。
72. git rebase –continue:继续执行rebase操作。
73. git grep -n [pattern] [file]:在指定文件中搜索指定的模式,并显示行号。
74. git commit –amend:将暂存区的变更合并到最近一次的提交中。
75. git branch -d [branch]:删除指定的分支。
76. git cherry-pick –skip:跳过当前正在进行的cherry-pick操作。
77. git reset –soft [commit]:将当前分支的HEAD指针移动到指定的提交,但不会删除提交的变更。
78. git revert –continue:继续执行revert操作。
79. git diff –staged:显示暂存区和最后一次提交之间的差异。
80. git push [remote] :[branch]:删除远程仓库上的指定分支。
81. git remote rename [old name] [new name]:将远程仓库的名称改为新的名称。
82. git stash drop [stash]:删除指定的暂存区。
83. git stash apply [stash]:将指定的暂存区恢复到当前分支,但不删除该暂存区。
84. git push –force:强制推送当前分支的变更到远程仓库。
85. git log –all:显示所有分支的提交历史。
86. git log –since=[date]:显示指定日期之后的提交历史。
87. git log –until=[date]:显示指定日期之前的提交历史。
88. git log –no-merges:显示提交历史中排除合并提交。
89. git diff [branch1] [branch2]:显示两个分支之间的差异。
90. git sparse-checkout init –cone:启用sparse-checkout模式,并只拉取指定目录下的文件。
91. git rebase –continue:继续执行rebase操作。
92. git grep -n [pattern] [file]:在指定文件中搜索指定的模式,并显示行号。
93. git commit –amend:将暂存区的变更合并到最近一次的提交中。
94. git branch -d [branch]:删除指定的分支。
95. git cherry-pick –skip:跳过当前正在进行的cherry-pick操作。
96. git reset –soft [commit]:将当前分支的HEAD指针移动到指定的提交,但不会删除提交的变更。
97. git revert –continue:继续执行revert操作。
98. git diff –staged:显示暂存区和最后一次提交之间的差异。
99. git push [remote] :[branch]:删除远程仓库上的指定分支。
100. git reset –hard [commit]:将当前分支的HEAD指针移动到指定的提交,并且丢弃暂存区和工作目录中的所有变更。2年前 -
1. git init:初始化一个新的Git仓库。
2. git clone [url]:克隆一个远程仓库到本地。
3. git add [file]:将文件添加到暂存区。
4. git commit -m [message]:提交暂存区的文件到版本库,并添加提交信息。
5. git status:查看文件状态。
6. git log:查看提交日志。
7. git diff:比较文件差异。
8. git branch:显示分支列表。
9. git branch [branch]:创建一个新的分支。
10. git checkout [branch]:切换到指定分支。
11. git merge [branch]:将指定分支合并到当前分支。
12. git remote:显示远程仓库信息。
13. git remote add [name] [url]:添加一个远程仓库。
14. git push [remote] [branch]:将本地分支推送到远程仓库。
15. git pull [remote] [branch]:从远程仓库拉取最新代码并合并到当前分支。
16. git fetch:从远程仓库拉取最新代码,但不合并。
17. git reset [file]:从暂存区移除文件。
18. git reset HEAD:取消暂存区的所有文件。
19. git checkout — [file]:撤销对文件的修改。
20. git rm [file]:从版本库和文件系统中删除文件。
21. git mv [old] [new]:重命名文件。
22. git stash:将当前工作目录的改动保存到堆栈中。
23. git stash list:显示保存在堆栈中的改动列表。
24. git stash apply:将堆栈中最近保存的改动应用到当前工作目录。
25. git stash drop:删除堆栈中最近保存的改动。
26. git cherry-pick [commit]:选择一个提交并将其应用到当前分支。
27. git commit –amend:修改最后一次提交。
28. git rebase [branch]:将当前分支的改动应用到指定分支上。
29. git tag [name]:为当前提交打上标签。
30. git tag -a [name] -m [message] [commit]:为指定提交打上带注释的标签。
31. git show [tag/commit]:显示标签或提交的详细信息。
32. git remote -v:显示远程仓库的详细地址。
33. git remote rename [old] [new]:重命名远程仓库的名称。
34. git remote remove [name]:移除指定名称的远程仓库。
35. git branch -d [branch]:删除指定分支。
36. git branch -m [old] [new]:重命名分支。
37. git log –oneline:以一行显示提交日志。
38. git log –graph:以图形显示提交历史。
39. git log –author=[author]:按作者过滤提交日志。
40. git log –since=[date]:按指定日期之后的提交过滤日志。
41. git log –grep=[pattern]:按指定模式匹配提交日志。
42. git blame [file]:显示文件的每一行是由谁修改的。
43. git show [commit]:[file]:显示指定提交中的文件内容。
44. git reflog:显示引用日志,包括撤销和重置操作。
45. git clean -n:显示将要被删除的未跟踪文件。
46. git clean -f:删除所有未跟踪的文件。
47. git bisect start:开始二分查找。
48. git bisect good:标记当前提交为“好”的提交。
49. git bisect bad:标记当前提交为“坏”的提交。
50. git bisect reset:退出二分查找模式。
51. git cherry-pick -n [commit]:选择一个提交但不应用到当前分支。
52. git cherry-pick -e [commit]:选择一个提交,并在提交信息中编辑。
53. git stash save [message]:保存改动并添加注释。
54. git stash pop:将堆栈中最近保存的改动应用到当前工作目录并从堆栈中删除。
55. git stash clear:清空堆栈中的所有改动。
56. git revert [commit]:反转指定提交的改动。
57. git remote show [remote]:显示指定远程仓库的详细信息。
58. git tag -n [tag]:显示指定标签的注释。
59. git tag -l:列出所有标签。
60. git blame -L [start], [end] [file]:只显示指定行数的文件注释。
61. git add .:将所有修改过的文件添加到暂存区。
62. git commit –amend -m [message]:修改最后一次提交的提交信息。
63. git rebase -i [commit]:交互式修改提交历史。
64. git reset [commit]:将HEAD指向指定的提交,同时重置暂存区。
65. git reset –hard [commit]:将HEAD指向指定的提交,同时重置暂存区和工作目录。
66. git push [remote] [local branch]:[remote branch]:将本地分支推送到远程仓库的指定分支。
67. git pull [remote] [remote branch]:[local branch]:从远程仓库拉取指定分支的代码并合并到本地分支。
68. git remote update:更新所有远程仓库的分支信息。
69. git branch -r:显示远程仓库的分支列表。
70. git push –tags:将本地所有标签推送到远程仓库。
71. git fetch [remote]:从远程仓库拉取最新代码,但不合并到任何分支。
72. git cherry-pick –abort:取消正在进行的 cherry-pick 操作。
73. git cherry-pick –continue:继续进行 cherry-pick 操作。
74. git branch -D [branch]:强制删除指定分支。
75. git push –force [remote] [branch]:强制推送指定分支到远程仓库。
76. git pull –rebase [remote] [branch]:从远程仓库拉取最新代码并合并到当前分支,使用rebase方式。
77. git reset [commit] [file]:从指定提交中恢复文件的内容。
78. git stash branch [branch]:创建一个新分支,同时将保存在堆栈中的改动应用到新分支上。
79. git revert –no-commit [commit]:反转指定提交的改动,并将改动应用到工作目录中。
80. git stash drop [index]:删除堆栈中的指定索引的改动。
81. git remote prune [remote]:删除远程仓库上已经不存在的分支。
82. git branch -u [remote]/[branch]:将当前分支与指定的远程分支进行关联。
83. git stash save –patch:保存改动,但只选择部分文件进行保存。
84. git stash clear % 想要知道有哪些 stash:清空堆栈中的全部改动。
85. git log –pretty=format:”%h – %an, %ar : %s”:以指定格式显示提交日志。
86. git diff [branch1]..[branch2]:比较两个分支之间的差异。
87. git rm –cached [file]:从Git中删除文件,但保留在文件系统中。
88. git blame -M [file]:显示文件的每一行是由谁修改的,并检测文件的重命名。
89. git tag -d [tag]:删除指定标签。
90. git stash show:显示保存在堆栈中的最近的改动。
91. git ls-files:列出当前工作目录下的所有文件。
92. git pull –rebase origin master:从远程仓库拉取最新代码,并将本地 master 分支上的改动应用到拉取的代码上。
93. git remote set-url [remote] [url]:修改指定远程仓库的URL地址。
94. git rebase –abort:取消正在进行的 rebase 操作。
95. git rebase –continue:继续进行 rebase 操作。
96. git submodule init:初始化子模块。
97. git submodule update:更新子模块。
98. git submodule add [url] [path]:将子模块添加到仓库中。
99. git submodule sync:将子模块的URL地址修改为与父仓库中的地址相同。
100. git restore –source=[commit] [file]:将指定文件恢复到指定提交中的版本。2年前