Aliasing your existing git branch

Aliasing your existing git branch

If you happened to miss the master branch and your organization has adopted the more popular main naming convention as the default branch, don’t worry! You can easily switch back to the previous environment without causing any issues. This can be done using a simple Git alias command, which allows you to create shortcuts for longer Git commands. By setting up an alias, you can quickly and efficiently switch between branches without having to remember the full command each time. This not only saves time but also reduces the chance of making errors when typing out commands. Here’s how you can set up a Git alias to switch back to the master branch:

git config --global alias.switch-master 'checkout master'

With this alias in place, you can simply type git switch-master to switch to the master branch.

Also you can create symlink for these git commands, for an example -

git symbolic-ref refs/heads/master refs/heads/main

This method ensures that you can seamlessly navigate between the main and master branches, maintaining your workflow without any disruptions.

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

Thank you for reading this article! If you're interested in DevOps, Security, or Leadership for your startup, feel free to reach out at or book a slot in my calendar. Don't forget to subscribe to my newsletter for more insights on my security and product development journey. Stay tuned for more posts!