开发者

'git pull' branch only

I have a git cloned repository.

The purpose of this repo is git log, as long there is no such thing as git log over ssh.

$ git ls-remote

ac118076af0ca4c164a831b9e31b1a307747ec36        refs/heads/master
db1253eae8241aa0813d5a49880c41cd810216c2        refs/heads/production/version-2011.10
32c2dcad3133c8214c0d0e898e32b7a7a9f068cf        refs/heads/release/version-2011.11

I would like to set-up a read-only branch only for git pull from remote machine (tracking branch?!).

$ git branch -tb version-2011.11 refs/heads/release/version-2011.11

fatal: git checkout: updating paths is incompatible with swit开发者_C百科ching branches.
Did you intend to checkout 'refs/heads/release/version-2011.11' which can not be resolved as commit?

$ git checkout -tb version-2011.11 release/version-2011.11

fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'release/version-2011.11' which can not be resolved as commit?

In future:

  • release/2011.11 will become a production/2011.11
  • master -> release/version-2011.12
  • and so on...

any suggestions?


git ls-remote shows you the refs in the remote repository, so refs/heads/release/version-2011.11 is only a valid ref in that repository, not your local clone. If the remote is called origin (as it would be by default) then your corresponding remote-tracking branch will be called:

refs/remotes/origin/release/version-2011.11

... or you can use the abbreviation: origin/release/version-2011.11 (The error you can see is from git trying to interpret the last parameter as a path, since it doesn't know of a ref with that name.)

If you just want to use git log, then you don't even have to create a local branch that tracks the remote-tracking branch - you can just do:

git log origin/release/version-2011.11

To update that remote-tracking branch (in case there have been changes in the remote repository) you can just do:

git fetch origin
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜