88个常用git命令

不及物动词 其他 61

回复

共3条回复 我来回复
  • fiy的头像
    fiy
    Worktile&PingCode市场小伙伴
    评论

    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 branch – 查看分支
    8. git checkout [branch] – 切换分支
    9. git merge [branch] – 合并指定分支到当前分支
    10. git remote -v – 查看远程仓库地址
    11. git remote add [name] [url] – 添加远程仓库
    12. git pull [remote] [branch] – 从远程仓库拉取代码到本地合并
    13. git push [remote] [branch] – 推送本地代码到远程仓库
    14. git fetch [remote] – 从远程仓库拉取代码,但不合并
    15. git stash – 将当前工作区的更改保存到一个新的堆栈中
    16. git stash pop – 恢复最近的一次stash,并从堆栈中删除
    17. git diff – 查看文件的差异
    18. git reset [commit] – 回退到指定的提交
    19. git remote remove [name] – 移除指定的远程仓库
    20. git rm [file] – 从版本控制中移除文件
    21. git mv [file] [new_file] – 重命名文件
    22. git show [commit] – 查看指定提交的详细信息
    23. git log –graph – 查看分支合并图
    24. git branch -d [branch] – 删除指定分支
    25. git tag [name] – 创建标签
    26. git tag – 查看标签
    27. git tag -a [name] -m [message] [commit] – 创建带有注释的标签
    28. git tag -d [name] – 删除标签
    29. git cherry-pick [commit] – 选择指定提交并应用到当前分支
    30. git rebase [branch] – 变基,将当前分支变基到指定分支
    31. git push –tags – 推送标签到远程仓库
    32. git blame [file] – 显示文件每一行的代码是由谁写的
    33. git config –global user.name [name] – 设置全局用户名
    34. git config –global user.email [email] – 设置全局用户邮箱
    35. git checkout [commit] — [file] – 恢复指定提交中的指定文件
    36. git log –stat – 查看提交日志及修改的文件列表
    37. git cherry-pick –abort – 取消当前的cherry-pick操作
    38. git fetch –prune – 获取最新代码,并清理本地不存在远程的分支
    39. git revert [commit] – 撤销指定提交的更改
    40. git remote prune [remote] – 清理本地不存在远程的分支和标签
    41. git bisect start -f – 启动一个二分搜索
    42. git blame -L [start],[end] [file] – 只显示指定行数范围内的代码作者
    43. git stash list – 查看堆栈中的stash列表
    44. git stash apply – 恢复最近的一次stash,并保留在堆栈中
    45. git stash drop – 删除最近的一次stash
    46. git stash clear – 清空堆栈中的所有stash
    47. git config –global color.ui true – 启用Git命令输出的颜色
    48. git config –global core.editor [editor] – 设置默认的文本编辑器
    49. git clean -f – 清理未被跟踪的文件
    50. git bisect bad – 标记当前版本为有问题的
    51. git bisect good [commit] – 标记指定提交为正常的
    52. git merge –abort – 取消当前的合并操作
    53. git diff –staged – 查看已暂存的文件与最后一次提交的差异
    54. git reflog – 查看引用日志
    55. git reset HEAD [file] – 取消已暂存的文件
    56. git reset –hard [commit] – 强制回退到指定的提交,并清除暂存区和工作区的更改
    57. git push [remote] :[branch] – 删除远程分支
    58. git push [remote] –tags – 推送所有标签到远程仓库
    59. git show-ref –tags – 查看所有标签的引用日志
    60. git cherry [branch_1] [branch_2] – 比较两个分支之间的差异
    61. git show –name-only [commit] – 查看指定提交修改了哪些文件
    62. git show –color [commit] – 以彩色输出方式展示指定提交的详细信息
    63. git ls-files – 查看被版本控制的文件列表
    64. git grep [pattern] – 查找包含指定模式的文件
    65. git blame -C [file] – 显示文件每一行的代码是由谁写的,并可追溯到复制和粘贴操作
    66. git mv [file_1] [file_2] – 移动或重命名文件
    67. git revert –no-commit [commit] – 撤销指定提交的更改,但不生成撤销提交
    68. git stash save [message] – 将当前工作区的更改保存到一个新的堆栈,并添加注释
    69. git stash branch [branch] – 基于指定的stash创建一个新分支
    70. git tag -l [pattern] – 根据指定模式列出匹配的标签
    71. git reflog show [branch] – 查看指定分支的引用日志
    72. git rebase –continue – 继续上一次失败的rebase操作
    73. git cherry-pick –edit – 选择并编辑一个提交后应用到当前分支
    74. git clean -n – 显示将要执行的清理操作,但不删除文件
    75. git bisect run [command] – 运行指定的命令,并自动标记提交是否有问题
    76. git show -s –format=%s – 查看最新一次提交的标题
    77. git show -s –format=%an – 查看最新一次提交的作者姓名
    78. git show -s –format=%ci – 查看最新一次提交的时间
    79. git reset –soft [commit] – 回退到指定提交,并将暂存区和工作区的更改保留
    80. git push –force [remote] [branch] – 强制将本地分支推送到远程仓库
    81. git stash apply –index – 恢复最近的一次stash,并将暂存区的更改也恢复
    82. git stash save –patch – 将当前工作区的更改保存到一个新的堆栈,但只添加部分文件
    83. git diff [branch_1] [branch_2] – 比较两个分支之间文件的差异
    84. git show HEAD – 查看最新一次提交的详细信息
    85. git show –name-status [commit] – 查看指定提交修改了哪些文件,并显示文件状态
    86. git reset [file] – 从工作区取消指定文件的更改
    87. git add –all – 将所有修改的文件添加到暂存区
    88. git stash drop [stash] – 删除指定的stash

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

    Git是一个版本控制系统,用于跟踪和管理项目中的代码变化。它提供了许多功能和命令,以下是88个常用的Git命令:

    1. git init:初始化一个空的Git仓库。
    2. git clone:克隆(下载)一个远程Git仓库到本地。
    3. git add:将文件添加到Git的暂存区。
    4. git commit:将文件提交到本地仓库。
    5. git push:将本地仓库的提交推送到远程仓库。
    6. git pull:从远程仓库拉取最新的代码到本地。
    7. git fetch:从远程仓库获取最新的分支和提交,但不合并到当前分支。
    8. git branch:列出本地所有的分支。
    9. git checkout:切换到指定分支或提交。
    10. git merge:将指定分支合并到当前分支。
    11. git rebase:将当前分支的提交放在另一个分支的顶部,以整理提交历史。
    12. git status:查看当前工作区的状态。
    13. git log:查看提交历史。
    14. git diff:查看工作区与暂存区的差异。
    15. git tag:创建、列出或删除标签。
    16. git remote:管理远程仓库。
    17. git stash:保存当前工作目录的状态,并清空工作区。
    18. git reset:撤销提交或回退到指定提交。
    19. git cherry-pick:选择某个提交并将其应用到当前分支。
    20. git blame:显示文件的每一行是谁修改的。
    21. git show:显示指定对象(提交、标签等)的详细信息。
    22. git grep:在工作目录中搜索指定的字符串。
    23. git config:配置Git的相关参数。
    24. git remote add:添加远程仓库。
    25. git remote remove:移除远程仓库。
    26. git remote rename:重命名远程仓库。
    27. git remote prune:清理无效的远程分支。
    28. git push origin –delete:删除远程仓库的指定分支。
    29. git branch -d:删除本地分支。
    30. git branch -r -d:删除远程跟踪分支。
    31. git branch -m:重命名分支。
    32. git log –oneline:以一行显示提交历史。
    33. git log –graph:以图形化方式显示提交历史。
    34. git log –after=日期:查看某个日期之后的提交历史。
    35. git stash save “message”:保存当前工作区的状态,并给状态命名。
    36. git stash apply:恢复最新的保存状态。
    37. git stash drop:删除最新的保存状态。
    38. git stash list:查看所有保存状态。
    39. git cherry-pick –abort:取消正在进行的 cherry-pick 操作。
    40. git rebase –continue:继续上次 rebase 操作。
    41. git branch -vv:查看本地分支与远程分支的对应关系。
    42. git diff HEAD~n:查看最新的n个提交与当前工作区的差异。
    43. git branch -a:列出本地和远程所有的分支。
    44. git blame -L 1,10 file:查看文件中指定行的修改者。
    45. git status -s:以简洁的方式查看工作区的状态。
    46. git log –author=author:根据作者筛选提交历史。
    47. git log –grep=pattern:根据提交的注释文本筛选提交历史。
    48. git log –since=date:查看指定日期之后的提交历史。
    49. git log –until=date:查看指定日期之前的提交历史。
    50. git log –name-only:仅显示提交涉及的文件。
    51. git log –name-status:显示每个提交修改的文件及其修改状态。
    52. git log –abbrev-commit:以缩略的方式显示提交历史。
    53. git log –no-merges:不显示合并提交。
    54. git log –follow file:查看指定文件的完整历史。
    55. git push origin –tags:将所有标签推送到远程仓库。
    56. git cherry-pick –no-commit:应用提交但不自动提交。
    57. git reset file:将文件从索引中移除,但不改变工作区。
    58. git restore file:撤销文件在工作区的修改。
    59. git checkout — file:撤销文件在工作区的修改。
    60. git revert commit:撤销指定提交所做的更改。
    61. git pull –rebase:拉取最新的代码并进行 rebase 操作。
    62. git log –stat:显示每个提交的修改统计信息。
    63. git log –pretty=format:”%h %an %s”:以指定的格式显示提交历史。
    64. git show commit:file:查看指定提交中的文件内容。
    65. git show HEAD^:查看上一次提交的详细信息。
    66. git tag -a tagname -m “message” commit:给指定提交打标签。
    67. git blame –date short file:以短日期格式查看文件的修改历史。
    68. git blame –show-email file:显示修改者的邮箱。
    69. git blame –show-name file:显示修改者的名字。
    70. git blame -w file:忽略空白字符的变更。
    71. git stash branch branchname stashname:基于某个保存状态创建新的分支。
    72. git diff –cached:查看暂存区与最近一次提交之间的差异。
    73. git diff branch1 branch2:比较两个分支之间的差异。
    74. git diff tag1 tag2:比较两个标签之间的差异。
    75. git cherry-pick -n commit:选择一个或多个提交但不自动提交。
    76. git mv file1 file2:将文件重命名。
    77. git ls-files:列出Git仓库中的所有文件。
    78. git remote -v:显示远程仓库的详细信息。
    79. git branch -vv:查看本地分支与远程分支的对应关系及其跟踪状态。
    80. git ls-remote origin:列出远程仓库的引用(分支、标签等)。
    81. git ls-tree commit:显示指定提交的树对象中的文件和目录。
    82. git reflog:查看引用的日志,包括分支、HEAD、标签等。
    83. git revert commit1 commit2:撤销从commit1到commit2之间的一系列提交。
    84. git push origin –force:强制推送本地提交到远程仓库。
    85. git push origin –all:推送所有本地分支到远程仓库。
    86. git push origin –tags:推送所有本地标签到远程仓库。
    87. git push –set-upstream origin branch:将本地分支与远程分支关联起来。
    88. git diff HEAD~n HEAD:查看最新的n个提交与当前工作区的差异。

    2年前 0条评论
  • worktile的头像
    worktile
    Worktile官方账号
    评论

    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_name]: 创建新的分支。
    10. git checkout [branch_name]: 切换到指定分支。
    11. git merge [branch_name]: 将指定分支合并到当前分支。
    12. git remote: 查看当前远程代码库的列表。
    13. git remote add [name] [url]: 添加一个新的远程代码库。
    14. git pull: 从远程代码库拉取并合并最新的代码。
    15. git push: 推送本地代码到远程代码库。
    16. git stash: 保存当前工作目录的修改。
    17. git stash apply: 恢复最近一次stash的修改。
    18. git cherry-pick [commit]: 将指定提交应用到当前分支。
    19. git reset [commit]: 撤销提交,并重置到指定提交。
    20. git rebase [branch]: 将当前分支的修改应用到指定分支。
    21. git tag: 查看标签。
    22. git tag [tag_name]: 创建一个新的标签。
    23. git show [tag]: 显示标签的详细信息。
    24. git branch -d [branch]: 删除指定分支。
    25. git fetch: 获取远程分支的最新代码。
    26. git checkout -b [branch_name]: 创建并切换到新的分支。
    27. git log –oneline: 查看简化的提交历史。
    28. git clean: 删除工作目录中未追踪的文件。
    29. git grep [text]: 在代码库中搜索指定文本。
    30. git blame [file]: 显示文件的每一行最后修改的提交。
    31. git remote -v: 查看远程代码库的详细信息。
    32. git cherry-pick [commit1] [commit2]: 选择多个提交并将其应用到当前分支。
    33. git revert [commit]: 撤销指定提交的修改,并创建一个新的提交。
    34. git reflog: 查看引用日志。
    35. git log –graph: 以图形方式查看提交历史。
    36. git log [file]: 查看指定文件的提交历史。
    37. git log –author=[author]: 查看指定作者的提交历史。
    38. git log –since=[date]: 查看指定日期之后的提交历史。
    39. git mv [old_file] [new_file]: 将文件名更改。
    40. git reset –hard [commit]: 重置到指定提交,并覆盖当前工作目录和暂存区。
    41. git diff [commit1] [commit2]: 显示两个提交之间的差异。
    42. git commit –amend: 修改最新的提交。
    43. git tag -a [tag_name] -m [message]: 创建带有注释的标签。
    44. git stash pop: 恢复最近一次stash的修改并从堆栈中删除。
    45. git clean -f: 强制删除工作目录中未追踪的文件。
    46. git show-branch: 显示所有分支的提交历史。
    47. git remote rm [name]: 删除指定的远程代码库。
    48. git push [remote] [branch]: 推送指定分支到指定的远程代码库。
    49. git fetch –prune: 获取最新的远程分支,并删除本地不存在的远程分支。
    50. git merge –no-ff [branch]: 禁止快速合并分支。
    51. git bisect start: 开始二分查找错误的提交。
    52. git bisect bad: 告诉Git当前版本存在问题。
    53. git bisect good [commit]: 告诉Git指定提交是正常的。
    54. git rebase -i [commit1] [commit2]: 交互式地重排提交历史。
    55. git cherry-pick -n [commit]: 应用指定提交的修改,但不自动生成新的提交。
    56. git diff HEAD^: 显示与最新提交的差异。
    57. git push –force: 强制推送代码到远程仓库。
    58. git log -p: 显示每个提交的详细修改。
    59. git commit –fixup [commit]: 创建一个用于修复指定提交的修复提交。
    60. git commit –squash [commit]: 创建一个用于合并指定提交的合并提交。
    61. git blame -L [start], [end] [file]: 仅显示指定行号范围内的注释。
    62. git bisect reset: 结束二分查找并重置到最新的版本。
    63. git pull –rebase: 从远程拉取代码并进行变基,以避免合并形成的无关提交。
    64. git stash list: 显示当前所有未恢复的stash。
    65. git stash drop [stash]: 删除指定的stash。
    66. git stash clear: 删除所有stash。
    67. git stash branch [branch]: 创建新的分支并将stash应用到新分支上。
    68. git diff –cached: 显示暂存区和最新提交之间的差异。
    69. git add -p [file]: 交互式地添加部分文件的修改到暂存区。
    70. git commit –amend –no-edit: 仅修改最新的提交的修改,而无需编辑提交信息。
    71. git log –author-time: 以作者时间排序显示提交历史。
    72. git log –committer=[committer]: 查看指定提交者的提交历史。
    73. git remote set-url [name] [url]: 修改指定远程代码库的URL。
    74. git push –tags: 推送本地所有标签到远程代码库。
    75. git branch -m [old_branch] [new_branch]: 将分支重命名。
    76. git show-branch [branch]: 查看指定分支的提交历史。
    77. git fetch –all: 获取所有远程分支的最新代码。
    78. git merge –abort: 取消合并操作。
    79. git cherry-pick –edit [commit]: 应用指定提交的修改并打开编辑器以编辑提交信息。
    80. git diff HEAD~[n]: 显示与最新的第n个提交的差异。
    81. git push [remote] –delete [branch]: 删除远程代码库上的指定分支。
    82. git log –grep=[pattern]: 查看提交信息中匹配指定模式的提交。
    83. git cherry-pick -x [commit]: 应用指定提交的修改,并将原始提交信息附加到新的提交上。
    84. git stash save [message]: 保存工作目录的修改并添加保存信息。
    85. git branch -a: 查看所有分支(包括本地和远程分支)。
    86. git tag -l [pattern]: 根据指定的模式查找标签。
    87. git commit -am [message]: 添加并提交所有已修改的文件,并添加提交信息。
    88. git blame -w [file]: 忽略空白字符,显示文件的每一行最后修改的提交。

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

400-800-1024

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

分享本页
返回顶部