git子树添加后,Git推送到主项目存储库会引发错误

问题描述 投票:0回答:1

[尝试使用git子树在多个项目中共享公共库文件。这是我一直遇到的问题。

1)添加子树,以便在我项目的“ jquery_treetable”子目录中。

$ git subtree add -P jquery_treetable ssh://[email protected]:29418/global_share/3pp/foss/jquery_treetable master --squash

添加子树后,gitk如下所示

gitk

2)将更新推送到主项目存储库(德语)

$ git push origin HEAD:refs/for/master
remote: Resolving deltas: 100% (1/1)
remote: Processing changes: refs: 1, done    
remote: ERROR: [36fb8f5] missing Change-Id in commit message footer
remote: 
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 [email protected]:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote: 
To https://gerrit.ericsson.se/a/lte/tools/mkdoc
 ! [remote rejected] HEAD -> refs/for/master ([36fb8f5] missing Change-Id in commit message footer)

3)git log如下图

enter image description here

4)我认为,由于在git log的第二次提交中缺少change-id(压缩过),我得到了拒绝。但是,如何为此南瓜子树添加Change-id。

git gerrit git-push git-subtree
1个回答
0
投票

您有两个未合并的提交(两个提交的提交日期都相同,所以我想两者都是在同一时间创建的并且没有被合并),问题不在于第一次提交,而是与第二次提交(错误消息)显示36fb8f5)在提交消息中有git-subtree且缺少change-Id时,gerrit将检查要合并的所有更改的更改id,您可能需要[]

[git reset --soft HEAD^1(如果要合并提交的先前更改)]

但是,如果您想解决手头的问题并保持一清二楚

git reset --hard HEAD^1

上面的命令现在应该将您的分支头位置带到36fb8f5

您可以使用]进行检查>

git log -2

现在执行

git commit --amend

现在检查更改ID是否附加到提交消息中,如果是,则可以推送更改,问题应该得到解决

© www.soinside.com 2019 - 2024. All rights reserved.