git爬坑笔记
这篇笔记是对git的一些高级用法的记录。持续更新……
git 操作
git checkout commit_id/HEAD~
git branch -f
git reverse
- git reset
- git reset –hard
彻底回到的那一次 commit,这中间发生的变更会完全消失(可以通过组合 git cherry-pick 来补充回来) - git reset –soft
回到的那一次 commit,这中间发生的变更不会消失,只是撤销中间的commit
- git reset –hard
- git revert # 提交一个新的commit去revert
git rebase -i
git rebase -i HEAD~
git rebase
git cherry-pick
git cherry-pick
git clone
没啥好说的,傻瓜操作
git pull / push
没啥好说的,傻瓜操作
git fetch
fetch 远端分支信息
git pull –rebase
= git fetch + git rebase
git pull
= git fetch + git merge
git branch
git branch -b
新建一个 branch
git branch -u
git branch -u
trace a branch
git branch -f
- git branch -f
/
将branch 强行切换到 branch_name2 或者一个 commit_id
git add remote
添加一个远端仓库,并起一个别名
可通过 git remote -v
查看远端,一般用于同步 github 主仓库和自己的仓库的分支 ,如 git checkout -b xxx master_repo/101_branch
git 删除分支
删除远程分支
1 | git push origin --delete <branch_name> |
删除本地分支
1 | git branch -D <branch_name> |