目录
新建分支
git checkout -b some_branch
git push origin some_branch
git branch --set-upstream-to=origin/some_branch
查看
查看所有远程分支
git branch -a
查看本地分支所对应的远程分支
git branch -v
拉取
拉取远程分支到本地(新建分支)
git checkout -b 本地分支名 origin/远程分支名
删除
删除本地分支
git branch -D br
删除远程分支
git push origin :br
git push origin --delete
添加
添加所有修改
git add -A
git commit -a -m ""
日志
查看前两次diff
git log -p -2
git log --stat
git log --graph
git log --since=2weeks
git log --until
git log --oneline --decorate
回滚
回滚到指定版本
# 回滚到指定的版本 git reset --hard e377f60e28c8b84158 # 强制提交 git push -f origin master
git rm log/*.log
git checkout [file]
文件
补充文件
$ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend git branch --all git reset HEAD [files]
撤销修改
git checkout -- [file] git remote -v git remote show git remote rm [name] git remote add git fetch [remote-name] git fetch origin 并不会做merge git push [remote-name] [branch-name] git tag -a v1.2 9fceb02 git pull 会做Merge
git config
git config --global alias.co checkout git config --global alias.br branch git config --global alias.ci commit git config --global alias.st status git ls-remote git diff branch1..branch2
重命名
rename branch
git branch -m
#generate patch
git format-patch -1 HEAD
git pull --rebase