Git branch named origin/HEAD -> origin/master

前端 未结 3 398
轻奢々
轻奢々 2021-01-30 08:40

I\'m fairly new to Git, and still getting the hang of it. I just recently started working with branches and am running into some questions.

I have two development system

相关标签:
3条回答
  • HEAD usually points to the currently checked out branch. In hosted (bare) repositories, it designates the default branch, i.e. the branch that is checked out when you clone the repository. So, origin/HEAD tells you the default branch of origin.

    I don't know why it's not present in your repository on the Ubuntu system. Perhaps you originally pushed your code from that repository (when origin was empty and thus didn't have a HEAD yet) and never updated it.

    Having something like origin/HEAD is not terribly important in practice, anyway. If you want, you can use git remote set-head origin -a to have origin/HEAD created/updated

    To answer your other question: if you run git pull without arguments, it actually fetches everything from the remote (git fetch is run without arguments, too, so it just gets everything). Everything doesn't get merged, though. Only the remote-tracking branches (the stuff in git branch -r) are updated.

    0 讨论(0)
  • 2021-01-30 09:08

    As far as I know, HEAD is not a branch, but rather a pointer to a node of the history tree (i.e. a commit). The files which are residing in you particular working copy have the state described by HEAD.

    Usually HEAD points to the most recent commit in a branch, so you have the most recent files in the working copy. Using git reset HEAD^ you can shift the pointer to previous commit (i.e. undoing the last commit in your local copy).

    Now, every git repo has a HEAD, check this with git show HEAD. Accordingly, origin/HEAD is HEAD of your origin remote.

    Now, I've found a good question describing HEAD: What is HEAD in Git?

    0 讨论(0)
  • 2021-01-30 09:28

    It is just a pointer to master, a symbolic link if you wish. You can safely delete it by doing the following in a terminal (or git bash/cygwin for windows users):

    1. navigate to your repository
    2. execute: git remote set-head origin -d

    now it should be gone:

    $ git branch -r
    origin/master
    
    0 讨论(0)
提交回复
热议问题