Search code examples
gitversion-controlworkflow

Is it possible to have local aliases for branches?


My workplace uses YouTrack ticket names as branch names (e.g. MD-####). However this can look a bit factory-like in my Git desktop client and makes extra steps when returning to previously blocked work, etc.

Can i give my branches descriptive names locally for my sanity but not change the branch name on the repo?

Thanks in advance


Solution

  • Yes, your local branches do not need to have the same name as their corresponding remote branches. More generally, your local branches can define an upstream branch.

    Let's say you are interacting with a remote branch MD123 but a better semantic name for it would be nullPointerFix.

    You can create your local branch with the semantic name: git checkout -b nullPointerFix and then set it's upstream branch as MD123: git branch -u origin/MD123.

    Now, as you work on your semantically named local branch, you can git push and git pull from the remote branch.