HEAD branch

  • china-richway2
    9th Nov 2013 Member 0 Permalink

    I just discovered a HEAD branch in tracking branches.

    origin/HEAD

    and I cannot check it out.

    How to fix?

  • boxmein
    9th Nov 2013 Former Staff 0 Permalink
    HEAD is not a branch, it's the point in time where your current working directory is pointing to...

    For example, to take the working directory back into history three commits, you could do
    git checkout HEAD~3
    (this will detach the HEAD from any certain branch and give you the commit ID as the branch reference - from there you can create a branch referring to this given commit to keep any edits made)

    image
    For example, the above image is produced by these commands:

    git commit -m "C1"
    git commit -m "C2"
    git commit -m "C3"
    git commit -m "C4"
    git checkout HEAD~2
    git branch newBranch


    Edited 2 times by boxmein. Last: 9th Nov 2013
  • china-richway2
    9th Nov 2013 Member 0 Permalink

    What I asked is, how to fix this remote HEAD branch.

    But thanks your post, it is still useful anyways.

    Edited once by china-richway2. Last: 9th Nov 2013
  • boxmein
    9th Nov 2013 Former Staff 0 Permalink
    @china-richway2 (View Post)
    Well checking it out literally does nothing as well as saying "Would you mind moving your car to exactly where it is right now?"
    Edited once by boxmein. Last: 9th Nov 2013
  • china-richway2
    9th Nov 2013 Member 0 Permalink

    I sometimes want to push a branch that had just been re-based to origin. It askd me to pull. Then I merged. It created a dummy merge commit... Then I could upload it.

    Anyway how to delete that annoying HEAD branch?

    Edited once by china-richway2. Last: 9th Nov 2013
  • MiningMarsh
    9th Nov 2013 Member 0 Permalink

    @china-richway2 (View Post)

    You can't delete it because it is not a branch, it signifies your location on the current branch.

  • boxmein
    9th Nov 2013 Former Staff 0 Permalink
    @china-richway2 (View Post)
    HEAD is not a branch! What you listed in the first post is a ref and that is another thing: HEAD is a ref to "where i'm at right now".
  • china-richway2
    10th Nov 2013 Member 0 Permalink

    @MiningMarsh (View Post)

     

    @boxmein (View Post)

     I said, it becomes a remote tracking branch. Which is unexpected. I do not want it to be a remote tracking branch.

    Edited once by china-richway2. Last: 10th Nov 2013