User Tools

Site Tools


notes:tools:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
notes:tools:git [2019/04/01]
leszek [Branching]
notes:tools:git [2020/01/06] (current)
leszek
Line 184: Line 184:
 </​code>​ </​code>​
  
-Rename a branch:+Rename a local branch:
 <code text> <code text>
 git branch -m <​old_name>​ <​new_name> ​   # rename (move) a branch git branch -m <​old_name>​ <​new_name> ​   # rename (move) a branch
 +</​code>​
 +
 +Rename a local and a remote branch:
 +<code text>
 +# 1. Rename your local branch.
 +
 +# If you are on the branch you want to rename:
 +git branch -m new-name
 +
 +# If you are on a different branch:
 +git branch -m old-name new-name
 +
 +# 2. Delete the old remote branch and push the new local branch.
 +git push origin :old-name new-name
 +
 +# 3. Reset the upstream branch for the new-name local branch. Switch to the branch and then:
 +git push origin -u new-name
 </​code>​ </​code>​
  
notes/tools/git.txt ยท Last modified: 2020/01/06 by leszek