“git pull”仅限分行

发布于 2024-12-02 12:25:05 字数 1149 浏览 3 评论 0原文

我有一个 git 克隆存储库。

此存储库的目的是 git log ,只要没有诸如 通过 ssh 进行 git 日志

$ git ls-remote

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

我想仅为远程计算机上的 git pull 设置一个只读分支(跟踪分支?!)。

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

fatal: git checkout: updating paths is incompatible with switching 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?

将来:

  • release/2011.11 将成为 Production/2011.11
  • master -> release/version-2011.12
  • 等等...

有什么建议吗?

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 switching 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在夏天 2024-12-09 12:25:05

git ls-remote 显示远程存储库中的引用,因此 refs/heads/release/version-2011.11 只是该存储库中的有效引用,而不是本地克隆。如果远程被称为origin(默认情况下),那么您相应的远程跟踪分支将被称为:

refs/remotes/origin/release/version-2011.11

...或者您可以使用缩写:origin/release/version -2011.11 (您可以看到的错误来自 git 尝试将最后一个参数解释为路径,因为它不知道具有该名称的引用。)

如果您只想使用 git log ,那么你甚至不必创建一个跟踪远程跟踪分支的本地分支 - 您只需执行以下操作:

git log origin/release/version-2011.11

要更新该远程跟踪分支(以防远程存储库中发生更改),您只需执行以下操作:

git fetch origin

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文