运行< git worktree add>检查较旧的提交哈希

发布于 2025-02-08 09:48:06 字数 1089 浏览 1 评论 0原文

我正在运行Jenkins管道,其中:

[Pipeline] { (Prepare)
[Pipeline] sh
+ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

[Pipeline] sh
+ git fetch origin master
From https://github.com/<company>/ltlwrk-python
 * branch            master     -> FETCH_HEAD
   94b92f5..22c1a07  master     -> origin/master

[Pipeline] sh
+ git fetch origin test
From https://github.com/<company>/ltlwrk-python
 * branch            test       -> FETCH_HEAD
   223cb5f..7b13d20  test       -> origin/test

[Pipeline] sh
+ git fetch origin production
From https://github.com/<company>/ltlwrk-python
 * branch            production -> FETCH_HEAD
   54aad77..2e8a174  production -> origin/production

我运行一个config遥控器并取出3个分支,如所见。 在我打电话给git worktree之后,因为我想构建3 env。的一个容器,问题是,它不会检查最新的提交,并且当构建图像时,它具有旧代码在其中:( master:94b92f5-旧哈希。22C1A07-我想构建的新提交哈希)

git worktree add ./all/src_master master
git worktree add ./all/src_test test
git worktree add ./all/src_production production

我可能正在使用错误我想念吗?

Im running a jenkins pipeline, where:

[Pipeline] { (Prepare)
[Pipeline] sh
+ git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

[Pipeline] sh
+ git fetch origin master
From https://github.com/<company>/ltlwrk-python
 * branch            master     -> FETCH_HEAD
   94b92f5..22c1a07  master     -> origin/master

[Pipeline] sh
+ git fetch origin test
From https://github.com/<company>/ltlwrk-python
 * branch            test       -> FETCH_HEAD
   223cb5f..7b13d20  test       -> origin/test

[Pipeline] sh
+ git fetch origin production
From https://github.com/<company>/ltlwrk-python
 * branch            production -> FETCH_HEAD
   54aad77..2e8a174  production -> origin/production

I run a config remote and fetch 3 branches, as seen.
After I call on git worktree, because I want to build a single container of the 3 env., the problem is, it doesnt checks out the latest commit and when the image is build it has the old code in it:(master: 94b92f5 - old hash. 22c1a07 - new commit hash which I want to build upon)

git worktree add ./all/src_master master
git worktree add ./all/src_test test
git worktree add ./all/src_production production

I'm might be using the wrong git config, fetch, worktree command, i cant figure out which one, anyone knows what am I missing?

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

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

发布评论

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

评论(1

梦里南柯 2025-02-15 09:48:06

从日志中,我们可以看到分支testmaster生产未更新。相反,他们的远程跟踪分支ORIGIN/TESTOrigin/MasterOrigin/Production已更新。因此,请使用更新的远程跟踪分支来创建工作室。

git worktree add ./all/src_master origin/master
git worktree add ./all/src_test origin/test
git worktree add ./all/src_production origin/production

您可以首先检查测试,然后对其进行更新。但这不是您的情况。此外,Git不允许从同一分支创建一个以上的工人。第二次尝试将给出错误致命:如果未删除第一个工人,则已经在XXXX上检查了“主”。但是,它允许从同一提交或参考(例如onearch/master)或refs/heads/master创建多个工作室。

From the log, we can see that branches test, master, production are not updated. Instead, their remote tracking branches origin/test, origin/master, origin/production are updated. So use the updated remote tracking branches to create worktrees.

git worktree add ./all/src_master origin/master
git worktree add ./all/src_test origin/test
git worktree add ./all/src_production origin/production

You could checkout test first and then update it. But it's not necessary in your case. Besides, Git does not allow to create more than one worktree from the same branch. The second try would give an error fatal: 'master' is already checked out at xxxx, if the first worktree has not been removed. But it allows to create multiple worktrees from the same commit or ref like origin/master or even refs/heads/master.

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