How to find which git branch I am on when my disk is mounted on other server
Our git repo is on a Linux server; I can be on the master branch or create a new branch that I can go inside and use.
Our git repo disk is mounted on AIX box to build (I can see git directory in the AIX box that allows me to build)
In the AIX box how I can see that I am using master or inside a particular branch. What changes inside .git that drives which branch I am on?
Solution 1:
git branch
with no arguments displays the current branch marked with an asterisk in front of it:
user@host:~/gittest$ git branch
* master
someotherbranch
In order to not have to type this all the time, I can recommend git prompt:
https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
In the AIX box how I can see that I am using master or inside a particular branch. What changes inside .git that drives which branch I am on?
Git stores the HEAD
in the file .git/HEAD
. If you're on the master
branch, it could look like this:
$ cat .git/HEAD
ref: refs/heads/master
Solution 2:
Try using the command: git status
Solution 3:
You can look at the HEAD pointer (stored in .git/HEAD
) to see the sha1 of the currently checked-out commit, or it will be of the format ref: refs/heads/foo
for example if you have a local ref foo
checked out.
EDIT: If you'd like to do this from a shell, git symbolic-ref HEAD
will give you the same information.