当前位置:   article > 正文

常用git命令

常用git命令
# 初始化仓库
git init
# 设置全局用户名和邮箱
git config --global user.name "[name]"
git config --global user.email "[email address]"
# 将文件添加到暂存区
git add <file>
# 将所有修改过的文件添加到暂存区
git add .
# 提交暂存区的更改
git commit -m "commit message"
# 查看提交历史
git log
# 查看一行的提交历史
git log --oneline
# 查看工作目录和暂存区的差异
git diff
# 查看暂存区和上一次提交的差异
git diff --cached
# 撤销对文件的更改
git reset HEAD <file>
# 重置当前分支到指定状态
git reset --hard
# 列出所有本地分支
git branch
# 列出所有远程分支
git branch -r
# 创建并切换到新分支
git checkout -b <branch>
# 切换到指定分支
git checkout <branch>
# 将指定分支的更改合并到当前分支
git merge <branch>
# 从远程仓库拉取最新更改并自动合并到当前分支
git pull
# 将本地分支的更改推送到远程仓库
git push
# 推送指定分支到远程仓库
git push origin <branch>
# 查看远程仓库的详细信息
git remote -v
# 添加远程仓库
git remote add origin <repository>
# 使用工具解决合并冲突
git mergetool
# 应用补丁文件
git apply <patch-file>
# 查看补丁应用的摘要
git apply --summary <patch-file>
# 撤销补丁
git apply --reverse <patch-file>
# 从工作目录和暂存区删除文件
git rm <file>
# 删除已合并的本地分支
git branch -d <branch>
# 列出所有标签
git tag
# 创建新标签
git tag <tagname>
# 推送标签到远程仓库
git push --tags
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/909808
推荐阅读
相关标签
  

闽ICP备14008679号