重命名分支
#step1 重命名本地
git branch -m oldName newName
#step2 push 到远程
git push origin newName
#step3 删除远程旧分支
git push --delete origin oldName
Branches
- Topic分支:feature/hotfix/configuration change etc.
- Long last分支: master/develop/release
建立一个分支
git branch featureX
Checkout
image.pnggit checkout <branch_or_commit>
删除分支
git branch -d featureY #如果要强制删除则-D
恢复分支误删除(仅支持本地操作)git reflog
#假设分支被强制删除
$ git branch -D featureX
Deleted branch featureX (was e51fba2).
#第一步,查找分支
$ git reflog
88a0812 (HEAD -> master, origin/master) HEAD@{0}: commit: switch to master
d8d9cb0 HEAD@{1}: checkout: moving from featureX to master
e51fba2 HEAD@{2}: checkout: moving from master to featureX
#第二步
$ git checkout -b e51fba2 #-b代表指定 branch
Switched to a new branch 'e51fba2'
image.png
网友评论