I work on a bunch of different repos - many of them use master, and many of them use main.
I also have various shell aliases set up for git commands, e.g. gcm for git checkout master.
The problem is that I cannot use these aliases on repos where master doesn't exist. It's obviously not a big deal, because I just need to type out the command manually in that case, but it's slightly annoying.
I am wondering if there's a way I can "alias" branches in git, so when I say git push origin master it can just automatically replace that with main.
In a repository that has
main, but notmaster, the simplest is to create a branch aliasmasterthat points tomain:This gives the following list of branches (for example):
Now everytime your commands reference
masterthey apply tomain. Even when you pushmaster, the actual target ismain: