DEV Community

Cover image for Make an alias for existing branch
Michael Nikitochkin
Michael Nikitochkin

Posted on

Make an alias for existing branch

Photo by Mohammad Rahmani on Unsplash

If you happened to miss the master branch and your organization uses the more populistic main naming convention as the default branch, don't worry!
You can easily switch back to the previous environment without causing any issues using a simple Git alias command.:

$ git symbolic-ref refs/heads/master refs/heads/main
Enter fullscreen mode Exit fullscreen mode

This tool won't replace everything, but it can help you use old commands like:

$ git checkout master

$ git rebase -i master

$ git diff master
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
ccoveille profile image
Christophe Colombier

I would also add

$ git symbolic-ref refs/remotes/origin/master refs/remotes/origin/main
$ git symbolic-ref refs/remotes/upstream/master refs/remotes/upstream/main
Enter fullscreen mode Exit fullscreen mode

It has to be adapted to your git remote of course

Collapse
 
ccoveille profile image
Christophe Colombier

It's important to document how to remove the link if you dislike it

You can use git symbolic-ref -d

git symbolic-ref -d refs/heads/master
Enter fullscreen mode Exit fullscreen mode