0

I have been using git for some time already but this is the first time I have to deal with a master and a branch.

It happens on a directory /D I have created a branch and then checked out that branch on other directory /S. From /S I commited and pushed some changes. But when I want to pull those changes under /D I get the message that I'm "Already up-to-date". I thought maybe it was related to .gitignore, but it seems not.

Note: /D directory is local on my machine and /S directory is a mounted directory (on a Windows machione) from a network shared drive.

Situation within directory /D

git status command shows:

USER@PC MINGW64 /d/epptra2 (v2.8_beta_1.5_branch)
$ git status
On branch v2.8_beta_1.5_branch
Your branch is up-to-date with 'origin/v2.8_beta_1.5_branch'.

And git branch command shows:

USER@PC MINGW64 /d/epptra2 (v2.8_beta_1.5_branch)
$ git branch -a
  master
  origin
* v2.8_beta_1.5_branch
  remotes/origin/master
  remotes/origin/v2.8_beta_1.5_branch

Situation within directory /S

git status command shows:

USER@PC MINGW64 /s/epptra2 ((4c27924...))
$ git status
HEAD detached from origin/v2.8_beta_1.5_branch

And git branch command shows:

USER@PC MINGW64 /s/epptra2 ((4c27924...))
$ git branch -a
* (HEAD detached from origin/v2.8_beta_1.5_branch)
  master
  remotes/origin/master
  remotes/origin/v2.8_beta_1.5_branch

Questions

How can I get the changes I pushed to the branch under directory /S to be reflected under directory /D? And why was the HEAD detached from origin? Is there any command I may have done to detach the HEAD by mistake? If so, how can I fix this?

I had been pushing changes from /D and my collegues have been pulling changes from that branch with no issues. I still don't see why doing some update from another repository pointing to same branch would make this issue.

12
  • The way you (or someone) get (or got) a detached HEAD is by asking Git to git checkout --detach a branch name, or by using git checkout with something that is not a branch name, such as a tag name or remote-tracking name. origin/v2.8_beta_1.5_branch is a remote-tracking name, so git checkout origin/v2.8_beta_1.5_branch will result in a detached HEAD. This is normal! Just git checkout <whatever-branch> to change it.
    – torek
    Mar 17, 2020 at 23:03
  • Note, however, that any commits anyone made in this repository while using the detached HEAD will become very hard to find (and eventually, will be garbage-collected). Meanwhile, if you didn't do this, someone else did. Why? Find out who and why before you change it.
    – torek
    Mar 17, 2020 at 23:04
  • Last, note that when pushing to another repository, if that other repository has an index and work-tree—as any non-bare repository will—the other Git may reject your push. This is the default if you push to the branch they have checked-out. In general you should not push to non-bare repositories. Use a bare repository, which is one with no work-tree, so that no one can be doing any work in that repository, so that your push cannot break their in-progress work.
    – torek
    Mar 17, 2020 at 23:06
  • @torek Would it be possible for you to explain and publish your thoughts as an answer? I would certainly upvote. I'm working under a bare repository. The one doing changes by now was only me. And as you suspected I did checkout remotes/origin/v2.8_beta_1.5_branch, which is a tag I did push to be able to do checkout from other computers. Maybe this isn't best way to manage the situation I had, which was I found a bug and had to create a new branch and ask my collegues to checkout that branch and continue new commits from there till I could solve that bug. Mar 18, 2020 at 9:41
  • 1
    There's a decent (and free) book at git-scm.com/book/en/v2 and in this case you might look at think-like-a-git.net too.
    – torek
    Mar 19, 2020 at 17:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.