Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to alias a branch in Git?

I am looking into using Git on a massive scale. I was hoping to increase adoption and make things easier by calling the master branch trunk.

This can and will give SVN users some feelings of comfort. I know I can create a branch called trunk, but that seems to deviate from the Git norms and might cause some users to get confused.

I know that I can also create and delete tags to my heart's content but when I checkout those tags it tells me it is a non local branch which is just fine with me but probably not what I want to be doing.

I am a total Git newb but a seasoned professional at release and build systems.

What I want to do is to be able to call master trunk. I have seen the ability to alias commands – does this apply for the names of versioned objects as well?

I know git-svn exists and other tools but the overhead of layered repository systems frightens me.

like image 353
ojblass Avatar asked Feb 14 '09 22:02

ojblass


People also ask

Can branches be renamed?

The git branch command lets you rename a branch. To rename a branch, run git branch -m <old> <new>. “old” is the name of the branch you want to rename and “new” is the new name for the branch.

What is an alias git?

Git aliases are a powerful workflow tool that create shortcuts to frequently used Git commands. Using Git aliases will make you a faster and more efficient developer. Aliases can be used to wrap a sequence of Git commands into new faux Git command.

How do I copy a branch with a new name?

branch : add a --copy ( -c ) option to go with --move ( -m ) Add the ability to --copy a branch and its reflog and configuration, this uses the same underlying machinery as the --move ( -m ) option except the reflog and configuration is copied instead of being moved.

Where do I put git alias?

Your git aliases are often stored per your user's configuration at ~/. gitconfig . You can also manually set aliases using, for example, the command git config alias. s 'status -s' .


2 Answers

You can rename the master branch trunk as Greg has suggested, or you can also create a trunk that is a symbolic reference to the master branch so that both git and svn users have the 'main' branch that they are used to.

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

Note that trunk isn't a first class citizen. If you checkout trunk and perform a git status you will actually be on master, however you can use the trunk command in all places that you use the branch name (log, merge, etc.).

like image 185
CB Bailey Avatar answered Sep 30 '22 08:09

CB Bailey


There is nothing special about the name "master" in Git, it's just called that by convention (and by default). You can certainly call it "trunk" if you like:

git branch -m master trunk

This is very much like Subversion, where the name "trunk" is only called that by convention too. You could have called the main branch "master" in Subversion.

like image 11
Greg Hewgill Avatar answered Sep 30 '22 07:09

Greg Hewgill