Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange behavior with git fetch

I'm getting a big problem with GIT fetch...look this

$ git fetch
From server:project
   422b4cb..a04c062  master     -> origin/master

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/master

And another git fetch:

$ git fetch
From server:project
 + a04c062...422b4cb HEAD       -> origin/HEAD  (forced update)

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/master

And another one...

$ git fetch
From server:project
   422b4cb..a04c062  master     -> origin/master

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/master

And another git fetch:

$ git fetch
From server:project
 + a04c062...422b4cb HEAD       -> origin/HEAD  (forced update)

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/master

My refs/remotes/origin/HEAD and refs/remotes/origin/master always force update to 422b4cb...

What happened? 422b4cb... is a old commit.

like image 330
Miletos Avatar asked Feb 23 '11 18:02

Miletos


2 Answers

Wow...after a big fight with GIT I fixed this issue just using:

git push origin :HEAD
like image 163
Miletos Avatar answered Oct 06 '22 05:10

Miletos


The only other instance where I saw that kind of behavior was in this thread:

Looks like you have local branch 'HEAD' (not the special ref HEAD) on remote side and that is messing it up.

ls-remote'ing the repository shows 'refs/heads/HEAD', right (there's also HEAD, that's the required special ref)?

Maybe commit 422b4cb was when that branch called 'HEAD' was introduced?

Note (7 years later): with Git 2.16 (Q1 2018), you won't be able to create a branch named HEAD anyway.

like image 45
VonC Avatar answered Oct 06 '22 04:10

VonC