git p4 rebase尝试重新应用过去的提交

时间:2013-04-19 14:23:31

标签: git perforce git-p4

我遇到了git p4 rebase的问题,我不知道如何开始诊断问题,更不用说问题了。

所以我有一个由git-p4从perforce工作区克隆的git repo,它被用作远程仓库作为桥梁,所以团队可以使用git对抗一个远程仓库然后定期,我可以推送回购改回工作区。

通常,工作流程要么是人员在主分支上,要进行编辑,git -a commit是他们,再次git pull,然后git push将他们转到远程仓库,或者他们创建一个分支,然后在完成后将该分支合并回来,然后将主分支推送到远程。如果他们花了超过一天的时间,他们可能会偶尔推动分支。

当我将东西推回到perforce时,我在远程仓库中运行以下命令

git checkout -f
git clean -f
git p4 rebase --import-labels
git p4 submit -M --export-labels
git checkout -f
git clean -f

远程仓库不是裸露的,这就是我在

之前和之后运行结账并清理的原因

基本上一次又一次,在更改后被推回,当我执行git p4 rebase时,我收到以下错误

Performing incremental import into refs/remotes/p4/master git branch
Depot paths: //depot/sub/folder/
No changes to import!
Rebasing the current branch onto remotes/p4/master
First, rewinding head to replay your work on top of it...
Applying: A commit that has already been made previously
Applying: A second commit that has already been made in a previous commit
Using index info to reconstruct a base tree...
<stdin>:15: space before tab in indent.
                            a line of text
<stdin>:24: space before tab in indent.
                another line of text
<stdin>:25: space before tab in indent.
                a third line of text
<stdin>:33: trailing whitespace.
        a forth line of text
<stdin>:71: trailing whitespace.

warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging file from second
CONFLICT (content): Merge conflict in a/file/in/the/second/pre-existing/commit/file.php
Auto-merging a/file/in/the/second/pre-existing/commit/file.php
Failed to merge in the changes.
Patch failed at 0002 A second commit that has already been made in a previous commit

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

Traceback (most recent call last):
  File "/usr/lib/git-core/git-p4", line 3373, in <module>
    main()
  File "/usr/lib/git-core/git-p4", line 3367, in main
    if not cmd.run(args):
  File "/usr/lib/git-core/git-p4", line 3150, in run
    return self.rebase()
  File "/usr/lib/git-core/git-p4", line 3167, in rebase
    system("git rebase %s" % upstream)
  File "/usr/lib/git-core/git-p4", line 183, in system
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'git rebase remotes/p4/master' returned non-zero exit status 1

所以我有很多问题,在这里,当它正在执行git rebase时,作为git p4 rebase的一部分,它重新应用了一些已经应用于远程仓库并且已被推回的提交直到前一个git p4 rebase的工作区。重复提交来自哪里?为什么它仍然试图通过回购重播它们?

当我检查repo的工作副本中的文件时,它与工作区相同,因为自上一个git p4 rebase以来我没有做任何更改。结果git rebase --continue并没有真正做任何事情。

唯一的解决方案是运行git rebase --skip,但是当我这样做时,当我随后运行git p4 rebase并且每次都必须重新运行git rebase --skip时,会出现相同的消息。这令人气愤。

偶尔,我不完全确定在完成此消息之后,当我运行git p4 submit时,它实际上会将提交推送到p4工作区,从而导致重复的p4提交并弄乱文件。我相信当我运行git rebase --continue,然后git rebase --skip然后git p4 submit

时就会发生这种情况

当我检查git日志时,HEAD通常会在提交时超前,但是如何?

然后偶尔错误消失了,我无法确切地知道它消失的条件。

我怎么能开始解决这个问题?

1 个答案:

答案 0 :(得分:1)

我想我仍然对你的工作流程感到困惑。您是否直接将提交提交到Perforce,或者提交到运行git p4 submit的原始git仓库。如果你这样做,那么我认为这是你的主要问题。您需要将本地更改直接推送到Perorce,然后使用git p4 rebase同步所有内容。当你执行git p4 submit时,新的提交会在被推入perforce之前被修改,这就是为什么你不能先推送到另一个git repo的原因。

如果始终p4 submit来自创建comit的客户端计算机,则您的错误可能是由Perforce端的用户名/电子邮件的某种类型不匹配引起的。每个git commit sha1都使用作者电子邮件和提交日期(加上其他东西),如果这些值发生变化,那么git-p4 rebase可能会生成与本地不同的sha1并给出错误消息。

git-p4尝试通过为电子邮件映射文件创建perforce用户名来弥补这一点。我忘记了这个文件的保存位置,但如果你松开它,那么git-p4会变得混乱,并尝试重新应用你已经拥有的提交。

因此,解决方案要么不更改perforce端的电子邮件值,要么更改可能会混淆git-p4的任何其他内容。如果您在perforce中更改电子邮件,那么您必须确保保留原始映射文件,直到您从头开始重新导入所有提交。