Suppose I have the following branches in git:
master
release-2014-11-02-some-long-text
I would like to easily switch between those to, like this:
git checkout devel # checkout to master
git checkout release # checkout to the branch release currently points/aliases to, in this case: release-2014-11-02-some-long-text (I would like to change this alias from time to time)
How can I do that in Git?
It is important to note that there is no direct git alias command. Aliases are created through the use of the git config command and the Git configuration files. As with other configuration values, aliases can be created in a local or global scope.
Add git alias The simplest way to add a git alias is by running a command to add the alias to the git global configuration file. For example, running the command git config --global alias. hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short" will add the alias git hist .
You can try using git symbolic-ref
(as mentioned in "Is it possible to alias a branch in Git?"):
git symbolic-ref refs/heads/devel refs/heads/master
git symbolic-ref refs/heads/release refs/heads/release-2014-11-02-some-long-text
You can find a similar example in this gist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With