Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which git branch I am on when my disk is mounted on other server

Tags:

git

git-branch

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?

like image 294
user79292 Avatar asked Feb 20 '11 19:02

user79292


People also ask

How do I know which branch I cloned?

You successfully cloned a Git repository into a specific folder on your server. In this case, you cloned the master branch from your Git remote repository. You can check the current branch cloned by running the “git branch” command.

How do I get branches from remote repository?

If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.


1 Answers

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 
like image 176
ralphtheninja Avatar answered Oct 24 '22 05:10

ralphtheninja