git命令大全200个

不及物动词 其他 135

回复

共3条回复 我来回复
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    本文将为大家介绍200个常用的Git命令,帮助大家更好地使用Git进行版本控制。下面是具体的命令列表:

    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 [name]:创建一个新的分支
    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 [remote]:从远程仓库获取最新的代码,但并不合并
    17. git reset [commit]:回退到指定的提交
    18. git revert [commit]:撤销指定的提交
    19. git stash:将当前工作区的修改保存到一个临时区域
    20. git tag [name]:创建一个标签
    21. git show [tag/commit]:显示指定标签或提交的信息
    22. git rm [file]:删除一个文件
    23. git mv [file] [new_file]:重命名或移动一个文件
    24. git config –global user.name “[name]”:设置全局用户名
    25. git config –global user.email “[email]”:设置全局用户邮箱
    26. git reset –hard [commit]:将当前分支的HEAD指针指向指定的commit
    27. git bisect:通过二分搜索找出引入问题的特定提交
    28. git cherry-pick [commit]:选择一个特定的提交并将其应用到当前分支
    29. git blame [file]:显示指定文件的每行代码是由谁修改的
    30. git clean -f:清理未跟踪的文件
    31. git rebase [branch]:将当前分支的改动移动到指定分支上
    32. git remote update:更新远程仓库的信息
    33. git log –graph:以图形形式显示提交历史
    34. git remote show [remote]:显示指定远程仓库的详细信息
    35. git grep [pattern]:在工作目录中查找匹配指定模式的文件和内容
    36. git config –global alias.[name] [command]:创建一个指令别名
    37. git rebase -i [commit]:交互式的rebase,可以合并、编辑等
    38. git reflog:查看本地仓库的操作日志
    39. git fetch origin [branch]:从远程仓库获取指定分支的代码
    40. git push origin –delete [branch]:删除远程仓库的某个分支
    41. git commit –amend:修正最近的一次提交的提交信息
    42. git push –force:强制推送代码到远程仓库
    43. git revert –no-commit [commit]:撤销指定提交的改动,不产生新的提交
    44. git checkout — [file]:撤销对指定文件的修改
    45. git stash list:查看所有保存的临时区域
    46. git stash apply [stash_name]:将指定的临时区域应用到当前工作区
    47. git stash drop [stash_name]:删除指定的临时区域
    48. git stash pop:将最新保存的临时区域应用到当前工作区,并删除该临时区域
    49. git clean -n:显示将要被清理的未跟踪文件
    50. git clean -f -d:清理未跟踪的文件和文件夹
    51. git commit –allow-empty -m “[message]”:允许提交空的提交
    52. git commit –fixup=[commit]:创建一个fixup的提交,用于修复之前的提交
    53. git commit –squash=[commit]:合并之前的提交
    54. git log –oneline:以单行形式显示提交历史
    55. git log –stat:显示提交历史中的每个提交所修改的文件统计信息
    56. git log -S [keyword]:在提交历史中搜索包含指定关键字的提交
    57. git blame -L [start], [end] [file]:只显示指定范围内的代码行是谁修改的
    58. git diff [branch1] [branch2]:显示两个分支之间的差异
    59. git diff –cached:显示暂存区和HEAD之间的差异
    60. git diff [commit1] [commit2]:显示两个提交之间的差异
    61. git show [commit]:[file]:显示指定提交中的某个文件的内容
    62. git show [commit]:[directory]:显示指定提交中某个文件夹的内容
    63. git cherry-pick –continue:继续进行之前的cherry-pick操作
    64. git cherry-pick –abort:取消之前的cherry-pick操作
    65. git cherry-pick –quit:退出当前的cherry-pick操作
    66. git blame -w [file]:忽略空白字符的代码行是由谁修改的
    67. git blame -M [file]:查找代码文件中的文件移动
    68. git blame -C [file]:查找代码文件中的文件复制
    69. git blame -CC [file]:查找代码文件中的文件复制和移动
    70. git show-branch [branch1] [branch2]:显示两个分支之间的提交历史
    71. git stash branch [branch] [stash_name]:将指定的临时区域创建为一个新的分支
    72. git stash save [message]:保存当前工作区的修改,并添加一个备注
    73. git stash drop [stash_name]:删除指定的临时区域
    74. git stash clear:清理所有保存的临时区域
    75. git cherrypick -x [commit]:选择一个特定的提交并将其应用到当前分支,并保留原始提交记录
    76. git config [name]:显示指定配置项的值
    77. git config –global -e:修改全局的Git配置文件
    78. git config –local -e:修改当前仓库的Git配置文件
    79. git update-index –assume-unchanged [file]:将指定文件标记为不变更,以避免被误评估为修改
    80. git update-index –no-assume-unchanged [file]:取消对指定文件的不变更标记
    81. git stash show -p [stash_name]:显示指定临时区域的改动详细信息
    82. git reflog show [branch]:显示指定分支的操作日志
    83. git reflog delete [branch]:删除指定分支的操作日志
    84. git rev-parse –abbrev-ref HEAD:显示当前分支的名称
    85. git mv [file] [new_file]:重命名或移动一个文件
    86. git reset –hard [commit]:将当前分支的指针移动到指定的commit,并删除之后的所有commit
    87. git cherry-pick -e [commit]:选择一个特定的提交并将其应用到当前分支,并启动编辑提交信息
    88. git stash –patch:部分地保存当前工作区的修改
    89. git stash show [stash_name] -p:显示指定临时区域的改动详细信息
    90. git stash apply –index [stash_name]:将指定临时区域应用到当前工作区,并保留暂存区的状态
    91. git stash branch [branch] [stash_name]:将指定的临时区域创建为一个新的分支,并应用到该分支
    92. git merge –no-ff [branch]:合并指定分支到当前分支,并创建一个新的合并提交
    93. git fetch [remote] [branch] –prune:从远程仓库获取最新的代码,并删除无效的远程分支
    94. git tag -a [tag] -m “[message]” [commit]:为指定的commit创建一个标签,并添加一个备注信息
    95. git tag -d [tag]:删除指定的标签
    96. git show-ref –tags:显示所有的标签
    97. git tag –contains [commit]:显示包含指定commit的标签
    98. git branch -d [branch]:删除指定的分支
    99. git branch -D [branch]:强制删除指定的分支
    100. git branch -vv:显示所有分支的跟踪关系
    101. git branch -u [remote]/[branch]:设置当前分支的追踪关系
    102. git branch –merged:显示已合并到当前分支的分支
    103. git branch –no-merged:显示未合并到当前分支的分支
    104. git remote rename [old_name] [new_name]:将远程仓库的名称重命名
    105. git remote remove [name]:删除指定的远程仓库
    106. git push [remote] –delete [branch]:删除远程仓库的指定分支
    107. git push [remote] –tags:将本地的标签推送到远程仓库
    108. git push [remote] [local_branch]:[remote_branch]:将本地分支推送到远程仓库的指定分支
    109. git push [remote] [local_branch]:将本地分支推送到远程仓库,如果远程分支不存在则自动创建
    110. git push -f [remote] [branch]:强制推送代码到远程仓库
    111. git pull [remote] [branch]:从远程仓库拉取最新的代码,并自动合并
    112. git pull –rebase:从远程仓库拉取最新的代码,并使用rebase方式合并
    113. git fetch [remote] [branch]:从远程仓库获取最新的代码,但并不合并
    114. git stash save [message]:保存当前工作区的修改,并添加一个备注
    115. git stash pop:将最新保存的临时区域应用到当前工作区,并删除该临时区域
    116. git stash apply [stash_name]:将指定的临时区域应用到当前工作区
    117. git stash drop [stash_name]:删除指定的临时区域
    118. git stash clear:清理所有保存的临时区域
    119. git reflog:查看本地仓库的操作日志
    120. git reflog show [branch]:显示指定分支的操作日志
    121. git reflog delete [branch]:删除指定分支的操作日志
    122. git remote update:更新远程仓库的信息
    123. git log –graph:以图形形式显示提交历史
    124. git log –graph –oneline:以图形形式显示提交历史,并以单行形式显示每个提交
    125. git remote show [remote]:显示指定远程仓库的详细信息
    126. git grep [pattern]:在工作目录中查找匹配指定模式的文件和内容
    127. git grep -n [pattern] [file]:在指定文件中查找匹配指定模式的内容,并显示行号
    128. git config –global alias.[name] [command]:创建一个指令别名
    129. git config –global alias.[name] [command]:在全局Git配置文件中创建一个指令别名
    130. git config –local alias.[name] [command]:在当前仓库的Git配置文件中创建一个指令别名
    131. git stash drop [stash_name]:删除指定的临时区域
    132. git stash clear:清理所有保存的临时区域
    133. git diff [file1] [file2]:比较两个文件之间的差异
    134. git diff HEAD:比较工作区与最新提交之间的差异
    135. git diff [commit1] [commit2]:比较两个提交之间的差异
    136. git diff –name-only:只显示差异文件的文件名
    137. git diff –cached –name-only:只显示暂存区与最新提交之间的差异文件的文件名
    138. git diff [branch1] [branch2] –numstat:显示两个分支之间的差异统计信息
    139. git show [tag/commit]:显示指定标签或提交的信息
    140. git show [tag/commit] [file]:显示指定标签或提交中的某个文件的内容
    141. git show [tag/commit] [directory]:显示指定标签或提交中某个文件夹的内容
    142. git show [tag/commit1]…[commit2]:显示两个提交之间的差异
    143. git show [tag/commit] –name-only:只显示指定标签或提交中的差异文件的文件名
    144. git show [tag/commit] –name-status:显示指定标签或提交中的差异文件的文件名及变动状态
    145. git show [tag/commit] –stat:显示指定标签或提交中的差异文件的统计信息
    146. git rm [file]:删除一个文件
    147. git rm -r [directory]:递归地删除一个文件夹及其内容
    148. git mv [file] [new_file]:重命名或移动一个文件
    149. git mv [file1] [file2] [directory]:将多个文件移动到指定目录
    150. git mv [file_pattern] [directory]:将匹配指定模式的文件移动到指定目录
    151. git config –global user.name “[name]”:设置全局用户名
    152. git config –global user.email “[email]”:设置全局用户邮箱
    153. git config –local user.name “[name]”:设置当前仓库的用户名
    154. git config –local user.email “[email]”:设置当前仓库的用户邮箱
    155. git config –system user.name “[name]”:设置系统级的用户名
    156. git config –system user.email “[email]”:设置系统级的用户邮箱
    157. git reset [commit]:回退到指定的提交
    158. git reset –hard [commit]:将当前分支的HEAD指针指向指定的commit,并删除之后的所有commit
    159. git reset –soft [commit]:将当前分支的HEAD指针指向指定的commit,但保留之后的commit
    160. git reset [commit] [file]:将指定文件的状态恢复到指定提交的状态
    161. git reset –mixed [commit]:将当前分支的HEAD指针指向指定的commit,并将暂存区的内容恢复到指定commit
    162. git revert [commit]:撤销指定的提交,并创建一个新的提交来保存撤销操作
    163. git revert HEAD:撤销最近的一次提交
    164. git revert –no-commit [commit]:撤销指定提交的改动,但不创建新的提交
    165. git checkout [commit] [file]:将指定文件恢复到指定提交的状态
    166. git checkout [commit] [directory]:将指定文件夹恢复到指定提交的状态
    167. git checkout [branch]:切换到指定分支
    168. git checkout –

    2年前 0条评论
  • 不及物动词的头像
    不及物动词
    这个人很懒,什么都没有留下~
    评论

    1. git init:初始化一个新的git仓库。
    2. git clone:克隆远程仓库到本地。
    3. git add:将文件添加到暂存区。
    4. git commit:将暂存区中的改动提交到本地仓库。
    5. git push:将本地仓库中的改动推送到远程仓库。
    6. git pull:从远程仓库拉取最新的改动。
    7. git branch:查看本地分支。
    8. git checkout:切换分支或还原文件。
    9. git merge:将分支合并到当前分支。
    10. git stash:将当前工作保存在一个临时区域,以便切换到其他分支。
    11. git remote:查看远程仓库的信息。
    12. git fetch:从远程仓库获取最新的改动。
    13. git status:查看仓库的状态。
    14. git log:查看提交历史。
    15. git diff:查看文件的改动。
    16. git reset:将文件的更改还原到上一次提交的状态。
    17. git revert:撤销一次提交。
    18. git rm:从git仓库中移除文件。
    19. git mv:移动或重命名文件。
    20. git tag:给特定提交打上标签。
    21. git remote add:添加远程仓库。
    22. git remote remove:移除一个远程仓库。
    23. git remote rename:重命名一个远程仓库。
    24. git remote set-url:修改一个远程仓库的URL。
    25. git push –force:强制推送改动到远程仓库。
    26. git push origin –delete:删除远程分支。
    27. git pull –rebase:从远程仓库拉取改动并进行变基。
    28. git branch -d:删除本地分支。
    29. git branch -m:重命名本地分支。
    30. git stash apply:应用之前保存的工作。
    31. git stash pop:应用并删除之前保存的工作。
    32. git fetch –prune:拉取最新的改动并删除本地已经不存在的远程分支。
    33. git cherry-pick:选择某个提交并应用到当前分支。
    34. git rebase:将一个分支的改动合并到当前分支,并且修改提交的顺序。
    35. git rebase -i:交互式的修改和合并提交。
    36. git submodule:管理子模块。
    37. git bisect:二分查找到引入问题的提交。
    38. git blame:显示文件每一行的最后一次修改是由谁引入的。
    39. git config:配置git的相关设置。
    40. git archive:将git仓库打包为tar或zip文件。
    41. git stash list:查看保存的工作清单。
    42. git stash drop:删除保存的工作。
    43. git stash clear:清空保存的工作。
    44. git log –oneline:以简洁的形式查看提交历史。
    45. git log -p:显示每个提交的详细差异。
    46. git log –graph:以图形化的形式展示提交历史。
    47. git diff –staged:查看已经暂存但未提交的改动。
    48. git diff :查看两个提交之间的差异。
    49. git merge –no-ff:禁用fast-forward合并。
    50. git merge –abort:取消合并并还原到合并之前的状态。
    51. git reset –hard HEAD:将工作区的改动全部还原到上一次的提交。
    52. git reset –soft HEAD~1:撤销上一次提交,但保留更改。
    53. git reset –mixed HEAD~1:撤销上一次提交,并将更改放到工作区。
    54. git revert –no-commit
    :将某个提交的改动还原到工作区。
    55. git rm –cached :停止跟踪文件,但保留在工作区。
    56. git mv
    :移动或重命名文件。
    57. git tag -a -m ““:创建带注释的标签。
    58. git tag -d :删除标签。
    59. git push origin –tags:推送所有标签到远程仓库。
    60. git push origin
    :推送特定的标签到远程仓库。
    61. git remote -v:查看远程仓库的详细信息。
    62. git remote show :查看特定远程仓库的详细信息。
    63. git remote prune
    :删除本地已经不存在的远程分支。
    64. git config –global user.name ““:设置全局用户名。
    65. git config –global user.email ““:设置全局用户邮箱。
    66. git config –global core.editor ““:设置全局文本编辑器。
    67. git config –global color.ui true:启用彩色输出。
    68. git archive –format=zip –output=.zip :将特定提交打包成zip文件。
    69. git blame -L , :只显示特定行数的注释。
    70. git stash save ““:保存工作并添加注释。
    71. git stash branch :从当前保存的工作创建新的分支。
    72. git stash drop stash@{n}:删除特定的保存的工作。
    73. git stash apply stash@{n}:应用特定的保存的工作。
    74. git stash show stash@{n}:显示特定的保存的工作的差异。
    75. git stash clear:清空保存的工作。
    76. git log –grep=”“:根据模式查找提交记录。
    77. git log –before=”“:查找在特定日期之前的提交。
    78. git log –after=”
    “:查找在特定日期之后的提交。
    79. git diff –color-words:以单词为单位显示差异。
    80. git merge –strategy-option=ours :合并分支并保留当前分支的更改。
    81. git reset –mixed :将工作区和暂存区全部还原到特定的提交。
    82. git rev-parse HEAD:获取当前分支的SHA1值。
    83. git revert -n
    :撤销特定提交,但不创建新的提交。
    84. git cherry-pick –no-commit
    :选择某个提交但不创建新的提交。
    85. git rebase –onto :将分支3的改动应用到分支1上。
    86. git submodule init:初始化子模块。
    87. git submodule update:更新子模块。
    88. git submodule foreach :对每个子模块执行特定命令。
    89. git submodule sync:同步远程子模块的URL。
    90. git submodule add []:添加子模块。
    91. git submodule deinit :停止跟踪子模块。
    92. git config –global alias.“:创建git别名。
    93. git bisect start:开始二分查找。
    94. git bisect bad:标记当前提交有问题。
    95. git bisect good :标记特定的提交正常。
    96. git bisect reset:重置二分查找。
    97. git blame -L , -C :在文件的更改历史中查找特定行的移动。
    98. git blame -L :使用正则表达式查找文件中的特定行。
    99. git config –global core.autocrlf true:自动将换行符转换为CRLF。
    100. git config –global core.autocrlf input:自动将换行符转换为LF。
    101. git config –global core.eol “lf”:将换行符设置为LF。
    102. git merge –no-commit –squash :合并分支,但不自动创建新的提交。
    103. git reset –merge:取消合并并还原到合并之前的状态。
    104. git reset –hard :将工作区全部还原到特定的提交。
    105. git push –tags:推送所有的标签到远程仓库。
    106. git push origin ::删除远程分支。
    107. git remote set-url :修改远程仓库的URL。
    108. git remote show origin:查看远程仓库origin的详细信息。
    109. git remote prune origin:删除本地已经不存在的远程分支。
    110. git log –pretty=format:”%h – %an, %ar : %s”:定制提交历史的显示格式。
    111. git log –since=2.weeks:查找距今两周内的提交。
    112. git log –until=2021-01-01:查找直到2021-01-01之前的提交。
    113. git diff ..:查看两个提交之间的差异。
    114. git diff –word-diff:以单词为单位显示改动差异。
    115. git diff –ignore-all-space:忽略所有空格的改动差异。
    116. git merge –no-commit –no-ff :禁用fast-forward合并,并且不自动创建新的提交。
    117. git reset –hard HEAD^:将工作区和暂存区全部还原到上一次提交。
    118. git reset –soft HEAD^:撤销上一次提交,但保留更改和暂存区。
    119. git reset –mixed HEAD^:撤销上一次提交,并将更改放到工作区。
    120. git revert –no-edit :将某个提交的改动还原到工作区,并自动创建新的提交。
    121. git rm –cached -r :停止跟踪一个目录但保留在工作区。
    122. git mv :移动文件到指定目录。
    123. git stash list –grep=”“:按模式查找保存的工作。
    124. git stash drop stash@{n}:删除特定的保存的工作。
    125. git stash apply stash@{n}:应用特定的保存的工作。
    126. git stash show stash@{n} –patch:显示特定保存的工作的差异。
    127. git log –author=”“:查找特定作者的提交。
    128. git log –since=”2 weeks ago”:查找距今两周内特定作者的提交。
    129. git log –before=”2021-01-01″:查找直到特定日期之前特定作者的提交。
    130. git diff –color-moved:以彩色输出显示移动的内容。
    131. git merge –strategy-option=theirs :合并分支并接受特定分支的更改。
    132. git merge –strategy-option=recursive -X theirs
    :合并分支并接受特定分支的更改。
    133. git submodule init :初始化特定的子模块。
    134. git submodule update
    :更新特定的子模块。
    135. git submodule foreach –recursive :对所有子模块执行特定命令。
    136. git submodule sync
    :同步特定子模块的URL。
    137. git submodule add -f []:强制添加子模块。
    138. git submodule update –init –recursive:初始化并更新所有子模块。
    139. git bisect run :用特定命令自动检查每个提交。
    140. git config –global core.quotepath false:显示中文文件名。
    141. git blame -w :忽略空白字符查找文件中的特定行。
    142. git config –global core.editor “ -w”:设置在编辑器中打开文件时去除空白字符。
    143. git submodule foreach –recursive git pull origin master:更新所有子模块的master分支。
    144. git submodule foreach –recursive git checkout master:将所有子模块切换到master分支。
    145. git submodule foreach –recursive git merge origin/master:将所有子模块合并到master分支。
    146. git revert –no-commit –no-edit :今不创建新的提交撤销特定提交。
    147. git merge –ff-only :只允许快进合并分支。
    148. git push origin –delete
    :删除远程分支。
    149. git remote rename :重命名远程仓库。
    150. git update-index –assume-unchanged :告诉git该文件不会再更改。
    151. git update-index –no-assume-unchanged
    :告诉git该文件可能会更改。
    152. git stash list –format=”%h %s”:以简洁格式显示保存的工作。
    153. git stash drop stash@{n}:删除特定保存的工作。
    154. git stash apply –index stash@{n}:应用特定保存的工作并重新暂存文件。
    155. git log –grep=”” –author=”“:根据模式和作者查找提交。
    156. git log –all –grep=”“:在所有分支中查找提交。
    157. git diff –word-diff-regex=”“:使用自定义正则表达式显示差异。
    158. git merge –no-commit –no-ff –strategy-option=theirs :合并分支并接受特定分支的更改。
    159. git merge –no-ff –strategy-option=ours
    :合并分支并保留当前分支的更改。
    160. git submodule init :初始化特定的子模块。
    161. git submodule update
    :更新特定的子模块。
    162. git submodule foreach –recursive :对所有子模块执行特定命令。
    163. git submodule foreach –recursive git pull origin master:更新所有子模块的master分支。
    164. git submodule foreach –recursive git checkout master:将所有子模块切换到master分支。
    165. git submodule foreach –recursive git merge origin/master:将所有子模块合并到master分支。
    166. git revert –commit :将某个提交的更改还原到工作区,并创建新的提交。
    167. git merge –ff-only :只允许快进合并分支。
    168. git push origin –delete :删除多个远程分支。
    169. git remote rename :重命名远程仓库。
    170. git update-index –assume-unchanged :告诉git该文件不会再更改。
    171. git reset –merge :取消合并并还原到特定的合并提交。
    172. git stash list –format=”%h %s”:以简洁的方式查看保存的工作。
    173. git stash drop stash@{n}:删除特定的保存的工作。
    174. git stash apply –index stash@{n}:应用特定的保存的工作并重新暂存文件。
    175. git log –grep=”” –author=”“:根据模式和作者查找提交。
    176. git log –all –grep=”“:在所有分支中查找提交。
    177. git diff –word-diff-regex=”“:使用自定义的正则表达式显示差异。
    178. git merge –no-commit –no-ff –strategy-option=theirs :合并分支并接受特定分支的更改。
    179. git merge –no-ff –strategy-option=ours
    :合并分支并保留当前分支的更改。
    180. git submodule init :初始化特定的子模块。
    181. git submodule update
    :更新特定的子模块。
    182. git submodule foreach –recursive :对所有子模块执行特定命令。
    183. git submodule foreach –recursive git pull origin master:更新所有子模块的

    2年前 0条评论
  • fiy的头像
    fiy
    Worktile&PingCode市场小伙伴
    评论

    Git是一款分布式版本控制系统,它能够追踪文件的更改、协同开发以及管理代码的版本。在使用Git的过程中,我们需要掌握一系列的命令来完成各种操作。下面是200个常用的Git命令,按照不同的功能进行分类。

    版本控制命令
    1. git init:初始化一个新的Git仓库。
    2. git clone [url]:将远程仓库克隆到本地。
    3. git status:查看当前仓库的状态。
    4. git add [file]:将文件添加到暂存区。
    5. git commit -m [message]:将暂存区的文件提交到本地仓库,并添加一个描述信息。
    6. git diff:查看暂存区和工作区之间的差异。
    7. git log:查看提交历史。
    8. git checkout [commit]:切换到指定的提交。
    9. git reset [commit]:将HEAD指针重置到指定的提交。
    10. git branch:查看所有分支。
    11. git branch [branch_name]:创建一个新的分支。
    12. git checkout [branch_name]:切换到指定的分支。
    13. git merge [branch]:将指定分支合并到当前分支。
    14. git push [remote] [branch]:将本地仓库推送到远程仓库。
    15. git pull [remote] [branch]:将远程仓库的更新拉取到本地。
    16. git stash:将当前工作区的改动保存到一个临时区域。
    17. git tag [tag_name]:给当前提交打上标签。
    18. git blame [file]:显示指定文件的每一行代码是由谁修改的。
    19. git rm [file]:删除指定文件。
    20. git mv [file_old] [file_new]:将指定文件改名。

    分支管理命令
    21. git branch:查看所有分支。
    22. git branch [branch_name]:创建一个新的分支。
    23. git checkout [branch_name]:切换到指定的分支。
    24. git merge [branch]:将指定分支合并到当前分支。
    25. git branch -d [branch_name]:删除指定的分支。
    26. git branch -m [branch_old] [branch_new]:将指定分支改名。
    27. git branch -a:查看所有分支(包括远程分支)。
    28. git branch -r:查看远程分支。
    29. git checkout -b [branch_name]:创建一个新的分支,并切换到该分支。
    30. git push origin [branch_name]:将指定分支推送到远程仓库。

    标签管理命令
    31. git tag:查看所有标签。
    32. git tag [tag_name]:给当前提交打上标签。
    33. git tag -a [tag_name]:给当前提交打上带说明的标签。
    34. git tag -d [tag_name]:删除指定的标签。
    35. git tag -l [pattern]:查找匹配模式的标签。
    36. git show [tag_name]:显示指定标签的详细信息。
    37. git push origin [tag_name]:将指定标签推送到远程仓库。
    38. git push origin –tags:将所有标签推送到远程仓库。
    39. git checkout [tag_name]:切换到指定的标签。

    远程仓库命令
    40. git remote -v:查看当前仓库关联的远程仓库地址。
    41. git remote add [name] [url]:添加一个新的远程仓库。
    42. git remote rm [name]:删除指定的远程仓库。
    43. git remote rename [old_name] [new_name]:将指定的远程仓库改名。
    44. git fetch [remote]:从远程仓库更新本地的分支。
    45. git pull [remote] [branch]:将远程仓库的更新拉取到本地。
    46. git push [remote] [branch]:将本地仓库推送到远程仓库。
    47. git clone [url]:将远程仓库克隆到本地。
    48. git remote show [name]:显示指定的远程仓库的详细信息。
    49. git remote prune [remote]:删除本地不存在的远程分支信息。

    文件操作命令
    50. git add [file]:将文件添加到暂存区。
    51. git rm [file]:删除指定文件。
    52. git mv [file_old] [file_new]:将指定文件改名。
    53. git mv [file] [directory]:将指定文件移动到指定目录。
    54. git mv [directory_old] [directory_new]:将指定目录改名。
    55. git stash:将当前工作区的改动保存到一个临时区域。
    56. git stash pop:恢复最近一次stash的改动到工作区。
    57. git stash list:显示当前所有的stash记录。
    58. git stash apply [stash_id]:恢复指定的stash记录到工作区。

    查看信息命令
    59. git status:查看当前仓库的状态。
    60. git log:查看提交历史。
    61. git log -n [number]:查看指定数量的提交历史。
    62. git log –oneline:以简洁的方式显示提交历史。
    63. git log –graph:以图形的方式显示提交历史。
    64. git diff:查看暂存区和工作区之间的差异。
    65. git diff [commit1] [commit2]:查看两个提交之间的差异。
    66. git show [commit]:显示指定提交的详细信息。
    67. git diff [branch1] [branch2]:查看两个分支之间的差异。
    68. git blame [file]:显示指定文件的每一行代码是由谁修改的。
    69. git show-branch:显示所有分支的提交历史。
    70. git reflog:显示HEAD和分支的移动记录。

    配置命令
    71. git config –global user.name [name]:配置全局的用户名。
    72. git config –global user.email [email]:配置全局的邮箱地址。
    73. git config –global core.editor [editor]:配置全局的代码编辑器。
    74. git config –global alias.[command_name] [git_command]:使用别名定义一个新的git命令。
    75. git config –local [key] [value]:配置本地仓库的相关信息。

    合并命令
    76. git merge [branch]:将指定分支合并到当前分支。
    77. git merge –no-ff [branch]:执行非快进式合并,创建一个新的合并提交。
    78. git cherry-pick [commit]:将指定提交应用到当前分支。
    79. git cherry-pick [upstream]:将指定远程分支的最新提交应用到当前分支。
    80. git merge-base branch1 branch2:找出两个分支的最近共同祖先提交。

    重置命令
    81. git reset [commit]:将HEAD指针重置到指定的提交。
    82. git reset –hard [commit]:将HEAD指针和工作区都重置到指定的提交。
    83. git reset –soft [commit]:将HEAD指针重置到指定的提交,但保留工作区的改动。
    84. git reset HEAD~[number]:将HEAD指针和暂存区回退指定数量的提交。

    撤销命令
    85. git commit –amend:修改最新一次提交的描述信息。
    86. git reset –hard HEAD:撤销工作区的改动,并重置HEAD和暂存区到最新提交。
    87. git revert [commit]:反转指定的提交,并创建一个新的提交。

    搜索命令
    88. git grep [pattern]:在工作区的文件中搜索指定的模式。
    89. git grep –cached [pattern]:在暂存区的文件中搜索指定的模式。

    文件查找命令
    90. git ls-files:列出所有被当前仓库追踪的文件。
    91. git ls-files [directory]:列出指定目录下被当前仓库追踪的文件。

    分支合并冲突解决命令
    92. git diff –base file:查看合并冲突中共同祖先版本的内容。
    93. git diff –ours file:查看合并冲突中当前分支的内容。
    94. git diff –theirs file:查看合并冲突中另一个分支的内容。
    95. git merge -X ours [branch]:合并分支,并选择当前分支的改动作为冲突解决方案。
    96. git merge -X theirs [branch]:合并分支,并选择另一个分支的改动作为冲突解决方案。
    97. git checkout –theirs [file]:在合并冲突时,选择另一个分支的文件作为冲突解决方案。
    98. git checkout –ours [file]:在合并冲突时,选择当前分支的文件作为冲突解决方案。

    文件历史命令
    99. git ls-tree [commit]:[directory]:显示指定提交或分支下指定目录的文件列表。
    100. git ls-tree [commit]:[file]:显示指定提交或分支下指定文件的详细信息。

    文件对比命令
    101. git diff [commit1] [commit2] –stat:显示两个提交之间的差异统计信息。
    102. git diff [commit1] [commit2] –full-diff:显示两个提交之间的完整差异。

    补丁命令
    103. git format-patch [commit1] [commit2]:生成两个提交之间的补丁文件。
    104. git am [patch file]:应用补丁文件。
    105. git apply [patch file]:应用补丁文件。
    106. git apply –check [patch file]:检查补丁文件是否可以成功应用。

    子模块命令
    107. git submodule add [url] [path]:添加一个子模块。
    108. git submodule init:初始化子模块。
    109. git submodule update:更新子模块。
    110. git submodule foreach [command]:对每个子模块执行指定的命令。

    追踪分支命令
    111. git remote -v:查看当前仓库关联的远程仓库地址。
    112. git remote add [name] [url]:添加一个新的远程仓库。
    113. git remote rm [name]:删除指定的远程仓库。
    114. git remote rename [old_name] [new_name]:将指定的远程仓库改名。
    115. git fetch [remote]:从远程仓库更新本地的分支。
    116. git pull [remote] [branch]:将远程仓库的更新拉取到本地。
    117. git push [remote] [branch]:将本地仓库推送到远程仓库。

    分支管理命令
    118. git branch:查看所有分支。
    119. git branch [branch_name]:创建一个新的分支。
    120. git checkout [branch_name]:切换到指定的分支。
    121. git merge [branch]:将指定分支合并到当前分支。
    122. git branch -d [branch_name]:删除指定的分支。
    123. git branch -m [branch_old] [branch_new]:将指定分支改名。
    124. git branch -a:查看所有分支(包括远程分支)。
    125. git branch -r:查看远程分支。
    126. git checkout -b [branch_name]:创建一个新的分支,并切换到该分支。
    127. git push origin [branch_name]:将指定分支推送到远程仓库。

    标签管理命令
    128. git tag:查看所有标签。
    129. git tag [tag_name]:给当前提交打上标签。
    130. git tag -a [tag_name]:给当前提交打上带说明的标签。
    131. git tag -d [tag_name]:删除指定的标签。
    132. git tag -l [pattern]:查找匹配模式的标签。
    133. git show [tag_name]:显示指定标签的详细信息。
    134. git push origin [tag_name]:将指定标签推送到远程仓库。
    135. git push origin –tags:将所有标签推送到远程仓库。
    136. git checkout [tag_name]:切换到指定的标签。

    远程仓库命令
    137. git remote -v:查看当前仓库关联的远程仓库地址。
    138. git remote add [name] [url]:添加一个新的远程仓库。
    139. git remote rm [name]:删除指定的远程仓库。
    140. git remote rename [old_name] [new_name]:将指定的远程仓库改名。
    141. git fetch [remote]:从远程仓库更新本地的分支。
    142. git pull [remote] [branch]:将远程仓库的更新拉取到本地。
    143. git push [remote] [branch]:将本地仓库推送到远程仓库。
    144. git clone [url]:将远程仓库克隆到本地。
    145. git remote show [name]:显示指定的远程仓库的详细信息。
    146. git remote prune [remote]:删除本地不存在的远程分支信息。

    文件操作命令
    147. git add [file]:将文件添加到暂存区。
    148. git rm [file]:删除指定文件。
    149. git mv [file_old] [file_new]:将指定文件改名。
    150. git mv [file] [directory]:将指定文件移动到指定目录。
    151. git mv [directory_old] [directory_new]:将指定目录改名。
    152. git stash:将当前工作区的改动保存到一个临时区域。
    153. git stash pop:恢复最近一次stash的改动到工作区。
    154. git stash list:显示当前所有的stash记录。
    155. git stash apply [stash_id]:恢复指定的stash记录到工作区。

    查看信息命令
    156. git status:查看当前仓库的状态。
    157. git log:查看提交历史。
    158. git log -n [number]:查看指定数量的提交历史。
    159. git log –oneline:以简洁的方式显示提交历史。
    160. git log –graph:以图形的方式显示提交历史。
    161. git diff:查看暂存区和工作区之间的差异。
    162. git show [commit]:显示指定提交的详细信息。
    163. git diff [branch1] [branch2]:查看两个分支之间的差异。
    164. git blame [file]:显示指定文件的每一行代码是由谁修改的。
    165. git show-branch:显示所有分支的提交历史。
    166. git reflog:显示HEAD和分支的移动记录。

    配置命令
    167. git config –global user.name [name]:配置全局的用户名。
    168. git config –global user.email [email]:配置全局的邮箱地址。
    169. git config –global core.editor [editor]:配置全局的代码编辑器。
    170. git config –global alias.[command_name] [git_command]:使用别名定义一个新的git命令。
    171. git config –local [key] [value]:配置本地仓库的相关信息。

    合并命令
    172. git merge [branch]:将指定分支合并到当前分支。
    173. git merge –no-ff [branch]:执行非快进式合并,

    2年前 0条评论
注册PingCode 在线客服
站长微信
站长微信
电话联系

400-800-1024

工作日9:30-21:00在线

分享本页
返回顶部