开发者

Strange behavior with git fetch

开发者 https://www.devze.com 2023-02-13 13:10 出处:网络
I\'m getting a big problem with GIT fetch...look this $ git fetch From server:project 422b4cb..a04c062master-> origin/master

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

$ git fetch
From server:project
   422b4cb..a04c062  master     -> origin/master
开发者_StackOverflow社区
$ 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.


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

git push origin :HEAD


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.


I'm not sure what causes this problem, but you can fix it if you have shell access to the git repository:

$ [ ... log into shell on git server ...]
$ cd /path/to/repo.git
$ rm refs/heads/HEAD

It is the same as

$ git push origin :HEAD

in the working copy. In my case we have the repo set up to deny branch deletion, so I had to log in and do it manually in this case.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号