Running <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

我运行一个配置远程和获取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

我可能正在使用错误的git配置,fetch, worktree命令,我不知道哪一个,有人知道我错过了什么?

从日志中可以看出,test,master,production分支没有更新。相反,它们的远程跟踪分支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

你可以先签出test,然后再更新它。但对你来说没有必要。此外,Git不允许从同一个分支创建多个工作树。第二次尝试将给出错误fatal: 'master' is already checked out at xxxx,如果第一个工作树没有被删除。但是它允许从相同的提交或ref中创建多个工作树,如origin/master甚至refs/heads/master

最新更新