Reputation: 2538
I have create a new local repository (using git init, followed by adding and committing some files). Later I added a remote repository:
$git remote add br /home/user/work/git/bare/
I can see it through command git remote -v Also git fetch br was successful
When I switch to this repo, it gives following message:
$ git checkout br/master
Note: checking out 'br/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at a155c68... Added Makefile.in`
I did not understand the above text? what is 'detached HEAD' state?
Just to add:
$ git branch
* (no branch)
master
$
I am at no branch, how/why?
Upvotes: 0
Views: 75
Reputation: 6695
You checked out a commit pointed to by a remote branch (you can list them using git branch -r
). If it’s not pointed to by any local branch, it results in detached head. You should set br/master
as upstream of your local master
.
git checkout master
git branch -u br/master
You can then synchronize your local and remote master
branch using git push
and git pull
.
Upvotes: 1