【第零章】Git命令合集

一、仓库的新建

git init
git init [project-name]
git clone [url]

二、配置

git config --list
git config -e [–global]
git config [–global] user.name “[name]”
git config [–global] user.email “[email address]”

三、增加/删除

git add [file1] [file2]
git add [dir]
git add .
git add -p
git rm [file1] [file2]
git rm --cached [file]
git mv [file-original] [file-rename]

四、代码提交

git commit -m [message]
git commit [file1] [file2] … -m [message]
git commit -a
git commit -v
git commit --amend -m [message]
git commit --amend [file1] [file2] …

五、分支

git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout -b [branch]
git branch [branch] [commit]
git branch --track [branch] [remote-branch]
git checkout [branch-name]
git checkout -
git branch --set-upstream [branch] [remote-branch]
git merge [branch]
git cherry-pick [commit]
git branch -d [branch-name]
git branch -D [branch-name]
git push origin --delete [branch-name]
git branch -dr [remote/branch]

六、标签

git tag
git tag [tag]
git tag [tag] [tag]
git tag -d [tag]
git push origin :refs/tags/[tagname]
git show [tag]
git push [remote] [tag]
git push [remote] --tags
git checkout -b [branch] [tag]

七、查看信息

git status
git log
git log --stat
git log -S [keyword]
git log [tag] HEAD --pretty=format:%s
git log [tag] HEAD --grep feature
git log --follow [file]
git whatchanged [file]
git log -p [file]
git log -5 --pretty --oneline
git shortlog -sn
git blame [file]
git diff
git diff --cached [file]
git diff HEAD
git diff [first-branch]…[second-branch]
git show [commit]
git show --name-only [commit]
git show [commit]:[filename]
git reflog
git rebase [branch]

八、远程同步

git remote update
git fetch [remote]
git remote -v
git remote show [remote]
git remote add [shortname] [url]
git pull [remote] [branch]
git push [remote] --force
git push [remote] --all

九、撤销

git checkout [file]
git checkout [commit] [file]
git checkout .
git reset [file]
git reset --hard
git reset --keep [commit]
git revert [commit]
git stash
git stash pop

十、其他

git archive

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值