Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

change branch name on local and remote

How do I rename both a Git local and remote branch name?

1.Start by switching to the local branch which you want to rename:

git checkout <old_name>

2. Rename the local branch by typing:

git branch -m <new_name>

3. At this point, you have renamed the local branch.
   If you’ve already pushed the <old_name> branch to the remote repository ,
   perform the next steps to rename the remote branch.

4. Push the <new_name> local branch and reset the upstream branch:

git push origin -u <new_name>

5. Delete the <old_name> remote branch:

git push origin --delete <old_name>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #branch #local #remote
ADD COMMENT
Topic
Name
3+7 =