跟踪 git 中的remotes/p4/master 分支

发布于 2024-07-17 22:40:59 字数 148 浏览 3 评论 0原文

我正在克隆一个最初由 git-p4 生成的存储库。 git-p4 使用我想跟踪的“remotes/p4/master”分支。 我如何告诉克隆该存储库的 git 也跟踪遥控器/p4/master? 这样我就可以查看“origin/remotes/p4/master”或其他内容。

I'm cloning a repo that was first generated by git-p4. git-p4 uses a 'remotes/p4/master' branch that I would like to track. How do I tell git, which is cloning that repo, to track remotes/p4/master as well? That way I would be able to check out "origin/remotes/p4/master" or something.

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

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

发布评论

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

评论(1

就此别过 2024-07-24 22:40:59

您也可以调整获取属性以镜像这些引用,尽管不是作为标准克隆的一部分。

因此,如下序列:

git clone ~/p4/git/services/info-service.git
cd info-service
git config --add remote.origin.fetch +refs/remotes/p4/*:refs/remotes/origin/p4/*
git fetch origin

这将在 info-service.git 中获取 refs/remotes/p4/release/1.1 例如 refs/remotes/origin/ p4/release/1.1 在你的克隆中,你可以使用 git checkout -b r1.1-fixes origin/p4/release/1.1 来创建一个基于它的分支 话

虽如此,在我的 Perforce 副本存储库中,我创建实际分支来镜像所有 p4 远程分支,主要是为了避免执行上述所有操作。 它还让我有机会修复从 p4 路径前缀到 git 分支名称的命名(因此 p4/main 变为 masterp4/release/1.1< /code> 变为 r1.1 等)。 我使用我自己的 p4-to-git 复制,但是您可以通过使用 git for-each-ref 循环 p4 远程引用并使用 git update- 设置本地分支来执行相同的操作参考

You can adjust the fetching properties to mirror those references as well, although not as part of a standard clone.

So a sequence like:

git clone ~/p4/git/services/info-service.git
cd info-service
git config --add remote.origin.fetch +refs/remotes/p4/*:refs/remotes/origin/p4/*
git fetch origin

This will fetch refs/remotes/p4/release/1.1 for example in info-service.git to be refs/remotes/origin/p4/release/1.1 in your clone, and you could create a branch based on it with git checkout -b r1.1-fixes origin/p4/release/1.1

Having said all that, in my Perforce replica repos, I create actual branches to mirror all the p4 remote branches, largely to avoid having to go through all the above. It also gives me a chance to fix up the naming from p4 path prefixes to git branch names (so p4/main becomes master, p4/release/1.1 becomes r1.1 etc). I use my own p4-to-git replication, but you could do much the same by looping over the p4 remote refs with git for-each-ref and setting local branches using git update-ref.

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