The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,100 other followers

How to rename git local & remote branches, and local & remote tags

Posted by jpluimers on 2020/08/06

Since I keep forgetting the difference and order between renaming branches and tags.

Note you need to repeat the origin steps for each remote!

[WayBack] How to rename git local and remote branches:

git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

Like tags below, be aware of the implications when renaming branches: if you pushed before other users already can have the old branch and have acted upon it.

[WayBack] git tag – How do you rename a Git tag? – Stack Overflow:

old^{}
git tag -d old
git push origin :refs/tags/old
git push origin refs/tags/new

Be aware, of the [WayBackimplications that a Git Tag change has to consumers of a package!

Note the first step is not just a plain git tag new old

The reason is that this will create a tag new pointing to the tag old, failing to point to the actual commit behind old. A more detailed explanation, including how to better handle renames, is at [WayBackgit tag – Why isn’t my tag listed when I checkout with Git GUI? – Stack Overflow

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: