运行< git worktree add>检查较旧的提交哈希
我正在运行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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从日志中,我们可以看到分支
test
,master
,生产
未更新。相反,他们的远程跟踪分支ORIGIN/TEST
,Origin/Master
,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 branchesorigin/test
,origin/master
,origin/production
are updated. So use the updated remote tracking branches to create worktrees.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 errorfatal: '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 likeorigin/master
or evenrefs/heads/master
.