git checkout master | |
git push origin HEAD:newBranchName | (1) Create a new branch remotely |
git branch newBranchName | (2) Create a new branch locally |
git checkout newBranchName | (3) Checkout the new branch |
git pull origin oldBranchName | (4) Remote old ==> Local new branch |
git push origin newBranchName | (5) Local new branch ==> Remote new |
git branch – - set-upstream newBranchName origin/newBranchName | (6) set up local branch to track remote branch |
git branch –d oldBranchName | (7) delete local old branch |
git push origin : oldBranchName | (8) delete remote old branch |
Note I: the local branch can be renamed by:
git branch -m oldBranchName newBranchName
Note II: step (1), (2) and (6) can be combined into a single command:
git branch newBranchName origin/newBranchName
Filed under: Programming Tagged: git rename branch locally remotely
