我开始使用子树,但现在结束了混乱。谷歌和手册页没有帮助,我可以找到如何解决这个错误。有人有主意吗?
- 回购:https://github.com/Azd325/gitkraken
- 操作系统:macOS 11.5.1
- git:git版本2.32.0
错误:
➜ git subtree split -P gitkraken --rejoin
cache for 12d7b0ee9414ebd0414070d22fb40db7446badd9 already exists!
示例来从外部复制它。
mkdir test
cd test
git init
touch readme.md
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git add readme.md
git commit -m "add readme"
git subtree add --prefix gitkraken "aur@aur.archlinux.org:gitkraken.git" master
git subtree split -P "gitkraken" --rejoin
目前,在我的repo中,我将文件夹切换到gitkraken-aur
,因此它暂时再次工作。
从第一个答案开始尝试删除子树文件夹。
test on main [?]
➜ rm -rf .git/subtree-cache
test on main [?]
➜ git subtree split -P "gitkraken" --rejoin
cache for 12d7b0ee9414ebd0414070d22fb40db7446badd9 already exists!
test on main [?]
➜ git subtree pull -P gitkraken "aur@aur.archlinux.org:gitkraken.git" master -m "Merge subbtree gitkraken"
From aur.archlinux.org:gitkraken
* branch master -> FETCH_HEAD
Already up to date.
test on main [?]
➜ git subtree push -P gitkraken "aur@aur.archlinux.org:gitkraken.git" master
git push using: aur@aur.archlinux.org:gitkraken.git master
cache for 12d7b0ee9414ebd0414070d22fb40db7446badd9 already exists!
test on main [?]
➜ rm -rf .git/subtree-cache
test on main [?]
➜ git subtree push -P gitkraken "aur@aur.archlinux.org:gitkraken.git" master
git push using: aur@aur.archlinux.org:gitkraken.git master
cache for 12d7b0ee9414ebd0414070d22fb40db7446badd9 already exists!
更多调试信息以尝试一个。
test on main [?]
➜ rm -rf .git/subtree-cache
test on main [?]
➜ tree .git
.git
├── COMMIT_EDITMSG
├── FETCH_HEAD
├── HEAD
├── ORIG_HEAD
├── branches
├── config
├── description
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── pre-merge-commit.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ ├── prepare-commit-msg.sample
│ ├── push-to-checkout.sample
│ └── update.sample
├── index
├── info
│ └── exclude
├── logs
│ ├── HEAD
│ └── refs
│ └── heads
│ └── main
├── objects
│ ├── 0c
│ │ └── ce20ac9c41edfaafd245059b066f4e644b6c84
│ ├── 23
│ │ └── 9ec593c6a2192e76c005435f748b2ad28be832
│ ├── 69
│ │ └── 3d7dd0cbe326ad51fffad7408c2c6cc8af7e0d
│ ├── 74
│ │ └── 11ec84b161eba98f6ae09d2210c231393c977c
│ ├── 84
│ │ └── a5dcf23e618a493da589f95f2c57da22603e2a
│ ├── 99
│ │ └── 03d6d6b962b96143f3e2c0b75550561de14c06
│ ├── b3
│ │ └── 5caa9cbb57f55fb05260b3dd767f92c62a20ba
│ ├── bf
│ │ └── 52649a7b94057b0da0a7f1bb20c55b395717be
│ ├── e4
│ │ └── 22b2b19b0c80773ccbad0822130158a024ef59
│ ├── e6
│ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│ ├── eb
│ │ └── 4c7f2ebf6596f7e3c40b2355bc11e7a1badf58
│ ├── info
│ └── pack
│ ├── pack-542055b17c2fb18100e23d143d0f824b0c5ee19f.idx
│ └── pack-542055b17c2fb18100e23d143d0f824b0c5ee19f.pack
└── refs
├── heads
│ └── main
└── tags
23 directories, 37 files
test on main [?]
➜ git subtree split -P "gitkraken" --rejoin
cache for 12d7b0ee9414ebd0414070d22fb40db7446badd9 already exists!
test on main [?]
➜ tree .git
.git
├── COMMIT_EDITMSG
├── FETCH_HEAD
├── HEAD
├── ORIG_HEAD
├── branches
├── config
├── description
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── fsmonitor-watchman.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── pre-merge-commit.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ ├── pre-receive.sample
│ ├── prepare-commit-msg.sample
│ ├── push-to-checkout.sample
│ └── update.sample
├── index
├── info
│ └── exclude
├── logs
│ ├── HEAD
│ └── refs
│ └── heads
│ └── main
├── objects
│ ├── 0c
│ │ └── ce20ac9c41edfaafd245059b066f4e644b6c84
│ ├── 23
│ │ └── 9ec593c6a2192e76c005435f748b2ad28be832
│ ├── 69
│ │ └── 3d7dd0cbe326ad51fffad7408c2c6cc8af7e0d
│ ├── 74
│ │ └── 11ec84b161eba98f6ae09d2210c231393c977c
│ ├── 84
│ │ └── a5dcf23e618a493da589f95f2c57da22603e2a
│ ├── 99
│ │ └── 03d6d6b962b96143f3e2c0b75550561de14c06
│ ├── b3
│ │ └── 5caa9cbb57f55fb05260b3dd767f92c62a20ba
│ ├── bf
│ │ └── 52649a7b94057b0da0a7f1bb20c55b395717be
│ ├── e4
│ │ └── 22b2b19b0c80773ccbad0822130158a024ef59
│ ├── e6
│ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│ ├── eb
│ │ └── 4c7f2ebf6596f7e3c40b2355bc11e7a1badf58
│ ├── info
│ └── pack
│ ├── pack-542055b17c2fb18100e23d143d0f824b0c5ee19f.idx
│ └── pack-542055b17c2fb18100e23d143d0f824b0c5ee19f.pack
├── refs
│ ├── heads
│ │ └── main
│ └── tags
└── subtree-cache
└── 24098
├── 12d7b0ee9414ebd0414070d22fb40db7446badd9
├── 9903d6d6b962b96143f3e2c0b75550561de14c06
├── e9aad069b8e1e49f8cbb54cb91e3f226e4949712
└── notree
26 directories, 40 files
3条答案
按热度按时间zzwlnbp81#
你需要通过删除
.git/subtree-cache
文件夹来清除子树缓存,你可以尝试在该文件夹中搜索12d7b0ee9414ebd0414070d22fb40db7446badd9
文件并删除它。然后再试一次执行你的命令。
我能够重现和修复的方式,答案是通过逆向工程的代码导致的错误:https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh#L329
e0bqpujr2#
我也遇到过同样的问题,花了很多时间去解决。
我的同事也有同样的问题,在重新安装了几次git之后,问题解决了,我问他使用的是哪个版本。
将git版本降级到2.30.2后,“缓存***exist”消息仍然出现,但“子树推送”操作成功运行
在我的例子中,有问题的git版本是2.35.2
rsaldnfx3#
我不知道这对调试这个问题是否有帮助,但我今天仍然在git 2.39.2版本中得到它。
我达到这一点的方法可能是添加git子树,然后删除它们,再重新添加相同的子树。
我的感觉是,如果历史中的某个地方有不止一个子树add,就会发生这种情况:
我已经解决了这个问题,在添加子树之前先从历史中的一部分分支出来,然后完全重新开始,这样就绕过了历史中子树被多次添加到同一路径的点。