• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Rename Local and Remote Git Branch

Written by Rahul, Updated on February 13, 2019

This tutorial will help you to rename a local git repository branch. Also, you can apply the same changes on the remote git repository.

Rename Local Git Branch

You can use -m option to rename a git branch. To rename the currently active branch just execute the following command with a new branch name.

git branch -m <new_branch_name>

To rename any other branch first define the name of the old branch name followed by the new branch name. For example:

git branch -m <old_branch_name> <new_branch_name>

Update Changes to Remote

Now, if you have already pushed the old branch to the remote. You can point a new branch to a new remote.

git push origin :<old_branch_name>
git push origin <new_branch_name>:refs/heads/<new_branch_name>

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

1 Comment

  1. Avatar Fabian Reply
    March 9, 2019 at 9:05 pm

    Thanks for the post

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy