</lylijincheng>

Git 常用的分支操作

Create a branch

Create a new develop branch based on remote

1
git checkout -b develop origin/develop

Push branch develop to remote

1
git push origin develop

Merge branch

Merge branch develop to branch master

1
2
git checkout master
git merge --no-ff develop

Merge and update

1
2
3
4
5
6
7
8
9
10
git checkout develop

# Update FETCH_HEAD
git fetch origin develop

# Merge feature to develop
git merge feature

# Merge remote branch to local's
git merge origin/develop

Delete branchs

Delete local branch release

1
git branch -d release

Delete remote branch release

1
2
3
4
git push origin :release

# or
git push origin --delete release

Delete remotes/origin/xxx

1
2
3
4
git branch --delete --remotes origin/xxx

# shorthand
git branch -dr origin/xxx

References

Comments