200条git命令大全
-
以下是常用的200条Git命令的详细列表:
1. git init:初始化一个新的仓库。
2. git clone [url]:从远程仓库克隆一个本地副本。
3. git add [file]:将文件添加到暂存区。
4. git commit -m “[message]”:将暂存区的文件提交到本地仓库。
5. git status:查看当前仓库的状态。
6. git diff:查看文件的修改内容。
7. git branch:列出本地分支。
8. git checkout -b [branch]:创建并切换到一个新的分支。
9. git checkout [branch]:切换到指定分支。
10. git merge [branch]:将指定分支的代码合并到当前分支。
11. git remote add [name] [url]:添加一个远程仓库。
12. git fetch [remote]:从远程仓库下载代码。
13. git pull:从远程仓库拉取代码并合并到当前分支。
14. git push [remote] [branch]:将当前分支的代码推送到远程仓库。
15. git log:显示提交历史记录。
16. git reset [commit]:重置当前分支的HEAD到指定的提交。
17. git stash:将当前工作区的修改保存到一个新的存储区域。
18. git tag [name]:给当前提交打标签。
19. git show [commit]:显示指定提交的详细信息。
20. git remote -v:查看远程仓库的详细信息。
21. git revert [commit]:撤销指定提交的修改。
22. git cherry-pick [commit]:选择一个提交并将其应用到当前分支。
23. git rebase [branch]:将当前分支的提交添加到另一个分支的最新提交之后。
24. git fetch –all:从所有远程仓库下载最新的代码。
25. git diff [branch1] [branch2]:比较两个分支之间的差异。
26. git blame [file]:显示指定文件的每一行代码是由谁修改的。
27. git push –tags:推送所有标签到远程仓库。
28. git clean -f:删除工作区中未被跟踪的文件。
29. git commit –amend:修改上一次的提交。
30. git config –global user.name [name]:设置全局用户名。
31. git config –global user.email [email]:设置全局用户邮箱。
32. git mv [file] [new_file]:重命名或移动一个文件。
33. git blame -L [start], [end] [file]:只显示指定行数的代码贡献者。
34. git branch -d [branch]:删除一个分支。
35. git stash apply:应用最近的存储的修改。
36. git stash drop:丢弃最近的存储的修改。
37. git stash list:列出所有存储的修改。
38. git stash pop:应用并删除最近的存储的修改。
39. git remote show [remote]:查看远程仓库的详细信息。
40. git remote remove [remote]:移除一个远程仓库。
41. git reset –hard [commit]:重置当前分支的HEAD和工作区到指定的提交。
42. git reset –soft [commit]:重置当前分支的HEAD到指定的提交,但保留工作区的修改。
43. git fetch –prune:下载远程仓库的代码并清除本地不存在的分支的追踪信息。
44. git log –graph:以图形化的方式显示提交历史记录。
45. git checkout [file]:撤销对文件的修改。
46. git pull –rebase:从远程仓库拉取代码并在本地进行变基。
47. git push –force:强制推送代码到远程仓库。
48. git tag -l:列出所有的标签。
49. git tag -a [name] -m “[message]” [commit]:给指定的提交打标签,并添加注释。
50. git reflog:显示HEAD的移动历史记录。
51. git branch -r:列出远程分支。
52. git checkout -b [branch] [remote]/[branch]:创建并切换到一个跟踪远程分支的本地分支。
53. git cherry-pick -n [commit]:选择一个提交但不自动提交。
54. git rebase –continue:继续进行变基操作。
55. git commit –fixup=[commit]:创建一个修复提交,用于修复之前的提交。
56. git commit –squash=[commit]:创建一个压缩提交,用于将之前的提交合并成一个。
57. git log –author=[author]:显示指定作者所提交的历史记录。
58. git diff –cached:查看已暂存文件与上次提交的差异。
59. git diff [commit1] [commit2] [file]:比较两个提交之间的指定文件的差异。
60. git remote prune [remote]:清除本地不存在的远程分支。
61. git merge –no-ff [branch]:使用普通合并模式将指定分支的代码合并到当前分支。
62. git bisect start:启动一个二分查找(bisect)会话。
63. git bisect bad:标记当前提交为有问题的提交。
64. git bisect good [commit]:标记指定提交为正常的提交。
65. git bisect reset:重置bisect会话。
66. git show [tag]:查看指定标签的详细信息。
67. git push [remote] –delete [branch]:删除远程仓库中的指定分支。
68. git commit –date=”[date]” -m “[message]”:使用指定日期创建提交。
69. git stash branch [branch] [stash]:从存储的修改创建一个新的分支。
70. git blame -C -L [start], [end] [file]:查找代码贡献者,包括复制粘贴的代码。
71. git commit -a -m “[message]”:将所有修改后的文件添加到暂存区并提交。
72. git cherry-pick –no-commit [commit]:选择一个提交但不自动提交并保留修改。
73. git rebase -i [commit]:交互式地重新执行提交。
74. git commit –fixup=[commit] [file]:在指定的提交中修复指定的文件。
75. git log –grep=[pattern]:通过提交的注释进行筛选。
76. git diff –stat:显示文件的修改统计信息。
77. git ls-files:列出所有被版本控制的文件。
78. git pull –rebase=preserve:从远程仓库拉取代码并在本地进行保留合并。
79. git push –tags –force:强制推送所有标签到远程仓库。
80. git tag -a [name] [commit]:给指定的提交打标签。
81. git reflog expire –expire-unreachable=now –all:清除不可达的提交。
82. git checkout -t [remote]/[branch]:创建并切换到一个跟踪远程分支的本地分支。
83. git cherry-pick –edit [commit]:选择一个提交并进行修改并自动提交。
84. git cherry-pick –continue:继续进行cherry-pick操作。
85. git merge –squash [branch]:使用压缩合并模式将指定分支的代码合并到当前分支。
86. git bisect run [command]:使用指定的命令运行二分查找。
87. git show-branch:显示分支之间的共同提交。
88. git show-ref –tags:显示所有标签的引用。
89. git push [remote] –delete-tag [tag]:删除远程仓库中的指定标签。
90. git revert –no-commit [commit]:撤销指定提交的修改但不自动提交。
91. git commit –date=”[date]” –amend:修改上一次提交的日期。
92. git stash branch [branch]:从存储的修改创建一个新的分支。
93. git blame -CCC -L [start], [end] [file]:查找代码贡献者,包括复制粘贴的代码和代码的变动。
94. git commit -a –amend -m “[message]”:修改上一次提交并覆盖提交信息。
95. git cherry-pick –no-commit [commit1]..[commit2]:选择一段提交但不自动提交并保留修改。
96. git rebase [branch1] [branch2]:将分支1上的提交变基到分支2上。
97. git commit –edit –reset-author:重置最后一次提交的作者。
98. git log –after=”[date]” –before=”[date]”:显示指定日期范围内的提交历史记录。
99. git diff [commit1] [commit2]:比较两个提交之间的所有差异。
100. git remote update:更新所有跟踪的远程分支。
101. git stash save “[message]”:将当前工作区的修改保存到一个新的存储区域并添加注释。
102. git stash apply –index:应用最近的存储的修改并保留暂存区的修改。
103. git stash drop [stash]:丢弃指定的存储的修改。
104. git stash list –grep=[pattern]:列出所有存储的修改并通过注释进行筛选。
105. git merge –abort:终止当前的合并操作并返回到合并前的状态。
106. git reset [commit] [file]:取消对指定文件的修改。
107. git pull –rebase=preserve –autostash:从远程仓库拉取代码并在本地进行保留合并,并自动应用存储的修改。
108. git push –tags –force-with-lease:强制推送所有标签到远程仓库,但需要确认推送前仓库状态没有发生变化。
109. git tag -a [name] [commit] -m “[message]”:给指定的提交打标签并添加注释。
110. git rebase -i –autosquash [commit]:交互式地重新执行提交并自动压缩提交。
111. git commit –fixup=[commit] –amend:创建一个修复提交并修改上一次提交。
112. git log –author=[author] –grep=[pattern]:通过提交的作者和注释进行筛选。
113. git diff –name-only [commit1] [commit2]:比较两个提交之间的差异,并只显示被修改的文件名。
114. git remote prune –dry-run:查看将要被删除的本地不存在的远程分支。
115. git show-branch [branch]:显示指定分支的提交历史记录。
116. git show-ref –tags -d:显示所有标签的引用,并显示标签指向的提交。
117. git push [remote] –delete :refs/tags/[tag]:删除远程仓库中的指定标签。
118. git revert –no-commit [commit1]..[commit2]:撤销一段提交的修改但不自动提交。
119. git commit –date=”[date]” –amend -m “[message]”:修改上一次提交的日期和提交信息。
120. git stash branch [branch] [stash]:从存储的修改创建一个新的分支并同时删除存储的修改。
121. git blame -CCC -C -L [start], [end] [file]:查找代码贡献者,包括复制粘贴的代码、代码的变动以及重命名的文件。
122. git commit -a –amend –no-edit:修改上一次提交并保持提交信息不变。
123. git cherry-pick –no-commit [commit1]…[commit2]:选择一段提交但不自动提交,并保留修改。
124. git rebase [branch1] [branch2] –committer-date-is-author-date:将分支1上的提交变基到分支2上,并保留原提交的作者和提交日期。
125. git commit –allow-empty -m “[message]”:创建一个空的提交。
126. git stash apply –reinstate:应用最近的存储的修改并只保留工作区的修改。
127. git stash drop [stash1] [stash2]:丢弃指定的存储的修改。
128. git stash list –grep=[pattern] –invert-grep:列出所有存储的修改并通过注释进行筛选,但排除匹配的注释。
129. git merge –abort –quiet:终止当前的合并操作并返回到合并前的状态,并禁止输出任何信息。
130. git reset [commit] — [file]:取消对指定提交中的指定文件的修改。
131. git pull –rebase=preserve –autostash –ff-only:从远程仓库拉取代码并在本地进行保留合并、自动应用存储的修改,并只允许快进合并(fast-forward)。
132. git push –tags –force-with-lease –no-verify:强制推送所有标签到远程仓库,但需要确认推送前仓库状态没有发生变化,并禁止验证钩子(hook)。
133. git tag -a [name] [commit] -m “[message]” –cleanup=strip:给指定的提交打标签并添加注释,同时清除注释的多余空白字符。
134. git rebase -i –autosquash –exec “[command]” [commit]:交互式地重新执行提交并自动压缩提交,并在每个提交后执行指定的命令。
135. git log –author=[author] –grep=[pattern] –all-match:通过提交的作者和注释进行筛选,但只显示符合所有匹配模式的提交。
136. git diff –name-only –diff-filter=[ACDMRTUXB] [commit1] [commit2]:比较两个提交之间的差异,并只显示被修改的文件名,并根据文件修改类型进行筛选。
137. git remote prune –dry-run –verbose:查看将要被删除的本地不存在的远程分支,并显示详细信息。
138. git show-branch [branch1] [branch2]:显示两个分支之间的共同提交的详细信息。
139. git show-ref –tags –deref-tags:显示所有标签的引用,并递归地显示标签所指向的提交。
140. git push [remote] –delete :refs/tags/[tag1] :refs/tags/[tag2]:删除远程仓库中的指定标签。
141. git revert –no-commit –no-edit [commit1]..[commit2]:撤销一段提交的修改但不自动提交,并保持提交信息不变。
142. git commit –date=”[date]” –amend –no-edit:修改上一次提交的日期,并保持提交信息不变。
143. git stash branch [branch] [stash1] [stash2]:从存储的修改创建一个新的分支并同时删除存储的修改,并指定多个存储的修改。
144. git blame -CCC -C -M -L [start], [end] [file]:查找代码贡献者,包括复制粘贴的代码、代码的变动、重命名的文件以及文件移动的修改。
145. git commit -a –amend –no-edit –reset-author:修改上一次提交并保持提交信息不变,并重置作者。
146. git cherry-pick –no-commit –ff [commit]:选择一个提交但不自动提交并尝试快进合并。
147. git rebase [branch1] [branch2] –committer-date-is-author-date –allow-empty:将分支1上的提交变基到分支2上,并保留原提交的作者和提交日期,同时允许创建空提交。
148. git commit —2年前 -
1. git init:初始化一个新的Git仓库。
2. git clone:克隆一个远程的Git仓库到本地。
3. git add:将文件添加到Git版本控制中。
4. git commit:将修改的文件提交到本地版本库。
5. git push:将本地的代码推送到远程仓库。
6. git pull:将远程仓库的代码拉取到本地。
7. git branch:创建、查看、删除分支。
8. git checkout:切换分支。
9. git merge:合并分支。
10. git status:查看文件状态。
11. git log:查看提交历史。
12. git diff:查看文件差异。
13. git rm:删除文件。
14. git mv:移动或重命名文件。
15. git stash:将当前工作保存到堆栈中。
16. git stash apply:恢复最近一次保存的工作。
17. git stash pop:恢复并删除最近一次保存的工作。
18. git stash list:查看保存的工作列表。
19. git stash drop:删除保存的工作。
20. git remote:管理远程仓库。
21. git fetch:从远程仓库中获取最新的代码。
22. git reset:将代码回退到指定的提交。
23. git revert:撤销指定的提交。
24. git tag:创建、查看、删除标签。
25. git blame:查看文件的每一行是谁修改的。
26. git config:配置Git仓库。
27. git remote add:添加远程仓库。
28. git remote remove:移除远程仓库。
29. git remote rename:重命名远程仓库。
30. git clean:清理未跟踪的文件。
31. git cherry-pick:选择一个或多个提交并应用到当前分支。
32. git rebase:将一系列提交合并到当前分支。
33. git bisect:用二分法查找导致Bug的提交。
34. git archive:创建一个压缩文件,包含指定的提交。
35. git blame:查看文件的每一行是谁修改的。
36. git grep:在项目中搜索指定的文本。
37. git reflog:查看引用的历史。
38. git show:显示某个提交的详细信息。
39. git reset:重新设置暂存区和工作区的状态。
40. git revert:创建一个新的提交,撤销指定的提交。
41. git tag:创建、查看、删除标签。
42. git cherry-pick:选择一个或多个提交并应用到当前分支。
43. git rebase:将一系列提交合并到当前分支。
44. git bisect:用二分法查找导致Bug的提交。
45. git stash:将当前工作保存到堆栈中。
46. git stash apply:恢复最近一次保存的工作。
47. git stash pop:恢复并删除最近一次保存的工作。
48. git stash list:查看保存的工作列表。
49. git stash drop:删除保存的工作。
50. git log:查看提交历史。
51. git log –oneline:以一行的方式显示提交历史。
52. git log –graph:以图形化的方式显示提交历史。
53. git log –author:按照作者过滤提交历史。
54. git log –since:按照时间过滤提交历史。
55. git log –grep:按照提交信息过滤提交历史。
56. git diff:查看文件差异。
57. git diff HEAD:查看工作目录与最新提交的差异。
58. git diff –staged:查看暂存区与最新提交的差异。
59. git diff commit1 commit2:查看两个提交之间的差异。
60. git difftool:使用外部工具查看文件差异。
61. git add:将文件添加到Git版本控制中。
62. git add -u:将已追踪的文件的修改添加到暂存区。
63. git add -A:将所有的修改添加到暂存区。
64. git add -p:按照每个修改的片段进行添加。
65. git commit:将修改的文件提交到本地版本库。
66. git commit -m “message”:提交并添加提交注释。
67. git commit –amend:修改最新一次提交的注释。
68. git commit –amend –no-edit:不修改注释的情况下重新提交。
69. git push:将本地的代码推送到远程仓库。
70. git push origin branch-name:将本地分支推送到远程仓库。
71. git push -u origin branch-name:将本地分支推送到远程仓库,并建立关联关系。
72. git push origin tag-name:将本地标签推送到远程仓库。
73. git pull:将远程仓库的代码拉取到本地。
74. git pull origin branch-name:将远程分支合并到本地当前分支。
75. git pull –rebase origin branch-name:将远程分支的提交应用到本地当前分支。
76. git branch:查看本地分支。
77. git branch branch-name:创建一个新的分支。
78. git branch -d branch-name:删除指定的分支。
79. git branch -m old-branch new-branch:重命名分支。
80. git checkout branch-name:切换到指定的分支。
81. git checkout -b branch-name:创建并切换到新的分支。
82. git checkout -:切换到上一个分支。
83. git merge branch-name:将指定分支的修改合并到当前分支。
84. git merge –no-ff branch-name:合并分支并创建一个新的提交。
85. git merge –squash branch-name:合并分支,并将多个提交合并为一个提交。
86. git merge –abort:终止当前的合并操作。
87. git reset:将代码回退到指定的提交。
88. git reset –hard commit:强制回退到指定的提交。
89. git reset –hard branch:强制回退到指定的分支的最新提交。
90. git reset –soft commit:回退到指定的提交,并保留修改。
91. git reset –mixed commit:回退到指定的提交,并取消暂存的修改。
92. git reset HEAD file:取消对指定文件的暂存。
93. git revert:撤销指定的提交。
94. git revert commit:创建一个新的提交,撤销指定的提交。
95. git revert –no-commit commit:取消指定的提交,并不创建新的提交。
96. git tag:创建、查看、删除标签。
97. git tag tag-name:创建一个新的标签。
98. git tag -a tag-name -m “message”:创建一个带有注释的标签。
99. git tag -l pattern:查找匹配指定模式的标签。
100. git tag -d tag-name:删除指定的标签。
101. git fetch:从远程仓库中获取最新的代码。
102. git fetch origin:从远程仓库的origin分支获取最新的代码。
103. git fetch origin branch-name:从远程仓库的origin分支获取最新的代码,并将其放到本地的branch-name分支。
104. git fetch –all:从所有远程仓库获取最新的代码。
105. git stash:将当前工作保存到堆栈中。
106. git stash save “message”:将当前工作保存到堆栈中,并添加注释。
107. git stash list:查看保存的工作列表。
108. git stash apply stash-name:恢复指定的保存的工作。
109. git stash pop stash-name:恢复并删除指定的保存的工作。
110. git stash drop stash-name:删除指定的保存的工作。
111. git stash clear:清空保存的工作。
112. git clean:删除未追踪的文件。
113. git clean -n:显示将要删除的未追踪的文件。
114. git clean -f:强制删除未追踪的文件。
115. git clean -df:强制删除未追踪的文件和文件夹。
116. git cherry-pick:选择一个或多个提交并应用到当前分支。
117. git cherry-pick commit:将指定的提交应用到当前分支。
118. git cherry-pick branch:将指定分支的提交应用到当前分支。
119. git cherry-pick -n commit:选择一个提交,但不应用。
120. git cherry-pick -e commit:选择一个提交,并在应用之前编辑提交信息。
121. git rebase:将一系列提交合并到当前分支。
122. git rebase branch:将指定分支的提交合并到当前分支。
123. git rebase commit:将当前分支的提交合并到指定的提交。
124. git rebase -i commit:交互式合并提交。
125. git rebase –continue:继续合并操作。
126. git rebase –abort:终止当前的合并操作。
127. git bisect:用二分法查找导致Bug的提交。
128. git bisect start:开始二分查找。
129. git bisect good:标记一个提交为没有Bug。
130. git bisect bad:标记一个提交为有Bug。
131. git bisect reset:重置二分查找。
132. git archive:创建一个压缩文件,包含指定的提交。
133. git archive -o file.zip commit:将一个提交创建为一个压缩文件。
134. git archive -o file.zip HEAD:将最新提交创建为一个压缩文件。
135. git blame:查看文件的每一行是谁修改的。
136. git blame file:查看指定文件的每一行是谁修改的。
137. git blame -L start,end file:查看指定文件的指定行范围是谁修改的。
138. git grep:在项目中搜索指定的文本。
139. git grep “text”:在工作目录中搜索指定的文本。
140. git grep -n “text”:显示搜索结果所在文件的行数。
141. git grep -c “text”:显示搜索结果的数量。
142. git grep –count “text”:显示搜索结果的数量。
143. git reflog:查看引用的历史。
144. git reflog show HEAD:查看HEAD引用的历史。
145. git reflog show branch-name:查看指定分支引用的历史。
146. git show:显示某个提交的详细信息。
147. git show commit:显示指定提交的详细信息。
148. git show branch-name:显示指定分支的最新提交的详细信息。
149. git show HEAD~1:显示HEAD的上一个提交的详细信息。
150. git show HEAD~2:显示HEAD的上两个提交的详细信息。
151. git show HEAD~N:显示HEAD的上N个提交的详细信息。
152. git reset:重新设置暂存区和工作区的状态。
153. git reset file:取消对指定文件的暂存。
154. git reset commit:取消对指定提交的暂存。
155. git reset HEAD:取消所有文件的暂存。
156. git reset –soft commit:回退到指定的提交,并保留修改。
157. git reset –mixed commit:回退到指定的提交,并取消暂存的修改。
158. git reset –hard commit:强制回退到指定的提交。
159. git reset –hard HEAD:强制回退到最新的提交。
160. git reset –hard HEAD~1:强制回退到上一个提交。
161. git reset –hard HEAD~2:强制回退到上两个提交。
162. git reset –hard HEAD~N:强制回退到上N个提交。
163. git config:配置Git仓库。
164. git config –global user.name “Your Name”:配置用户名。
165. git config –global user.email “your@email.com”:配置用户邮箱。
166. git config –global color.ui auto:配置命令行颜色。
167. git config –global core.editor “vim”:配置文本编辑器。
168. git config –global alias.st “status”:配置命令别名。
169. git remote:管理远程仓库。
170. git remote add origin url:添加一个远程仓库。
171. git remote remove origin:移除一个远程仓库。
172. git remote rename name new-name:重命名一个远程仓库。
173. git remote -v:查看当前仓库的所有远程仓库。
174. git remote show origin:查看指定远程仓库的详细信息。
175. git remote prune origin:删除不存在的远程分支。
176. git commit –amend:修改最新一次提交的注释。
177. git commit –amend –no-edit:不修改注释的情况下重新提交。
178. git commit –ammend -m “new message”:修改最新一次提交的注释,并提交。
179. git commit –fixup commit:创建一个标记为修复指定提交的提交。
180. git rebase -i –autosquash commit:自动合并修复提交。
181. git push origin :branch-name:删除远程分支。
182. git push origin tag-name:将本地标签推送到远程仓库。
183. git push –tags:将本地所有标签推送到远程仓库。
184. git pull origin remote-branch:从指定的远程仓库和分支拉取最新的代码。
185. git pull –rebase origin branch-name:将远程分支的提交应用到本地当前分支。
186. git stash apply stash@{n}:恢复指定的保存的工作。
187. git stash pop stash@{n}:恢复并删除指定的保存的工作。
188. git stash drop stash@{n}:删除指定的保存的工作。
189. git stash branch branch-name stash@{n}:创建一个新的分支,并将指定的保存的工作应用到新的分支。
190. git clean -n -d:显示将要删除的未追踪的文件和文件夹。
191. git clean -f -d:强制删除未追踪的文件和文件夹。
192. git cherry-pick -n commit:选择一个提交,但不应用。
193. git cherry-pick -e commit:选择一个提交,并在应用之前编辑提交信息。
194. git cherry-pick -x commit:选择一个提交,并在应用后(自动生成)添加一行注释。
195. git cherry-pick -s commit:选择一个提交,并在应用后(自动生成)添加签名。
196. git cherry-pick commit1 commit2:选择多个提交,并依次应用。
197. git rebase -i -x “command” commit:按提交交互式合并,并在合并之前执行命令。
198. git fetch origin –prune:从远程仓库获取最新的代码,并删除不存在的远程分支。
199. git stash push -m “message” file:将指定的文件保存到堆栈,并添加注释。
200. git reset –hard HEAD^:强制回退到上一个提交,并删除当前提交。
2年前 -
以下是200条常用的Git命令大全:
1. 初始化一个新的Git仓库:git init
2. 克隆一个远程的Git仓库:git clone [url]
3. 添加文件到Git仓库:git add [文件名]
4. 将添加的文件提交到本地仓库:git commit -m “提交信息”
5. 查看Git仓库的状态:git status
6. 查看文件的变化:git diff
7. 将本地的提交推送到远程仓库:git push
8. 创建一个新的分支:git branch [分支名]
9. 切换到指定分支:git checkout [分支名]
10. 合并指定分支到当前分支:git merge [分支名]
11. 删除分支:git branch -d [分支名]
12. 拉取远程仓库的最新代码:git pull
13. 查看所有分支:git branch
14. 查看提交日志:git log
15. 撤销上一次的提交:git revert HEAD
16. 重置当前分支到指定的提交:git reset [commit]
17. 恢复指定文件到指定的提交:git checkout [commit] [文件名]
18. 修改最后一次提交的提交信息:git commit –amend
19. 创建一个空的标签:git tag [标签名]
20. 创建一个带注释的标签:git tag -a [标签名] -m “注释”
21. 切换到指定标签:git checkout [标签名]
22. 列出所有标签:git tag
23. 删除一个标签:git tag -d [标签名]
24. 同步远程仓库的标签到本地:git fetch origin –tags
25. 清理无效的远程追踪分支:git remote prune origin
26. 查看远程仓库列表:git remote -v
27. 添加远程仓库:git remote add origin [url]
28. 移除指定的远程仓库:git remote rm [仓库名]
29. 重命名指定的远程仓库:git remote rename [旧名字] [新名字]
30. 创建一个新的空分支:git branch [新分支名] [起点]
31. 批量重命名文件:git mv [旧文件名] [新文件名]
32. 将文件从暂存区恢复到工作目录:git checkout [文件名]
33. 将文件从工作目录添加到暂存区:git add [文件名]
34. 创建一个空的提交:git commit –allow-empty -m “提交信息”
35. 使用自定义的模板提交:git commit -t [模板文件]
36. 修复最后一次提交:git commit –amend
37. 强制推送到远程仓库:git push -f
38. 恢复到某个指定的提交:git revert [commit]
39. 恢复到某个指定的提交,并将其作为一个新的提交:git cherry-pick [commit]
40. 从仓库中移除文件:git rm [文件名]
41. 查看分支合并情况:git branch –merged
42. 查看分支尚未合并的情况:git branch –no-merged
43. 查看指定文件的历史修改记录:git blame [文件名]
44. 修改提交信息:git rebase -i [commit]
45. 合并指定的commit:git rebase –continue
46. 合并多个commit:git rebase -i [commit]
47. 取消rebase操作:git rebase –abort
48. 切换到上一个分支:git checkout –
49
…
200.2年前