错误:无法应用--->通过查看指令,以适当的方式尝试它,但仍然错误的git壁球 [英] error: could not apply ---> tried it in proper way by seeing instructions but still errors for git squash

查看:129
本文介绍了错误:无法应用--->通过查看指令,以适当的方式尝试它,但仍然错误的git壁球的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的分支中,它显示了我的32个提交(John Smith),在这三个提交中另外两个开发者也是如此(Prince Rolf和Harry)。

对于一次提交,开发人员已经修改过。

现在

现在如果我试图挤压所有提交,我收到一个错误:

错误:无法应用ccdfa76 ...添加readme.md



我为这个错误搜索了一下,但无法找到它。

我尝试了十次然后十次挤压,但是也抛出了错误。

Can你们告诉我如何游泳,提供以下错误?



$ git rebase -i aaaa

  pick 04dc4d0 play:wip sports 
pick f255d38 play:sports


解决方案 c rebase with squash 没有失败。您看到的不是错误。



您的转发操作已被暂停

请仔细阅读以下消息:


已解决此问题时,运行git rebase --continue

如果您更喜欢跳过此修补程序,请运行git rebase --skip。

要查看原始分支和停止重新分配,请运行git rebase --abort

无法应用ccdfa7670a8eb780954edd1383e3378ef43292ac ...添加readme.md


查看建议的命令。 rebase / continue rebase / skip rebase
/ abort
。这基本上告诉你,rebase仍在进行中。它已暂停。你可以忽略这个问题并跳过,你可以做一些事情并继续,或者你可以彻底放弃(和回滚)rebase。



好的。所以我们知道情况如何。现在,让我们来检查一下为什么。

如果您阅读邮件,则知道它无法应用 ccdfa(..)


你无法检查状态,索引等,看看发生了什么,但你没有显示它们。所以,现在让我们使用你给我们的东西。



如果仔细阅读,我们可以在git log中注意到这个注释:


提交 c0ad7755f58f1bef92d71b72b8e1397b9e07fdea

合并:ccdfa76 b1ba9e4

作者:Prince Rolf

日期:2017年3月2日星期二19:07:32 2017 -0500

合并分支'git-module'的gitlab.cell .com:grp-imco-products / im-lap-sports进入体育模块



#冲突:

#README.md


看看喊叫的冲突。这不是你经常在提交信息中看到的东西。这是提交 c0ad77(..)(不是我们遇到问题的那个),但正如您在它的头文件中可以看到的,这是commit ccdfa76 (我们遇到问题)和 b1ba9e4 (迄今为止未知)。


$ b $现在看看提交树,让我们看看那些提交ID。


* 04dc4d0 play:wip sports

* c0ad775将gitlab.paper.com:chain/catch-sports合并分支<体育模块>合并到体育模块

| \

| * b1ba9e4 play:sports

| * a2464b1添加运动文件

| * 1a3cc30 play:wip sports

* ccdfa76 (origin / master)添加readme.md


嘿,它们都恰好处于历史的起点(底部)。大。它会简化查看它们。



b1ba9e4 位于 a2464b1之上code>,它依次位于 1a3cc30 之上 - 这就是您在rebase命令中写入的转化根。



c0ad775 确实是包含rebase-root的部分与 ccdfa76 (有问题的部分)之间的合并,现在,我们来看看你的rebase命令的开始:

  git rebase -i 1a3cc30 
挑选ccdfa76添加readme.md
壁球a2464b1添加运动文件
壁球b1ba9e4播放:运动
壁球04dc4d0播放: wip sports
squash f255d38 play:sports

详细命令现在不重要。重要的是你提出的有效的提交顺序

  0:1a3cc30 \(rebase根)
1:ccdfa76 ---:-----(有问题的一个)
2:a2464b1 |
3:b1ba9e4 /
- :( c0ad775)(合并,未在rebase计划中提及,所以不要求)
4:04dc4d0 ...
5:f255d38 ...

查看提交树,尝试注入 ccdfa76 (树的左侧)插入树的右侧中间。请记住, c0ad775合并将这两个树部分粘在一起,并在'readme'文件中有一个冲突。请记住 ccdfa76 消息说添加自述文件



因此,现在显然,当试图将 ccdfa76 应用于 1a3cc30 并且相同的冲突

显然, ccdfa76 会尝试添加一个自述文件文件,但是 1a3cc30 已经有自述文件。因此冲突。



这是我的猜测。现在开始进入控制台。



现在重新开始,清理所有内容。

使用与之前相同的计划执行rebase命令(pick / s /s/s/s/s.../s)。

等到不能应用ccdfa(..)出现。

请记住,rebase没有错误 - 它已暂停,因此您可以修复它并继续。

现在运行 git status 并查看它是什么说。



应该这样说:

  git status 
分支FOOBAR
#您有未合并的路径。
#(修复冲突并运行git commit)

#未合并路径:
#(使用git add ...标记分辨率)

#同时添加:readme.md

没有更改添加到提交中(使用git add和/或git commit -a)

好的,所以这个自述文件真的有冲突。现在你可以修复它。打开该文件,找到如下标记:

  bum 
<<<<<<<<<<<<<<<<<<<
bleh
=====
blah
>>>>>
whooo

这是合并冲突标记。我不会解释他们是如何工作的。在线阅读它,或者只是使用各种合并工具(比如KDiff3或WinMerge或其他)。

最重要的一点是:编辑文件并确保它看起来像你想看看。当你结束编辑时,应该没有标记。



当你修复冲突时,运行这个告诉git这个文件中的冲突都是固定的:

  git add readme.md 

是的。这只是简单的旧添加。之后,使用错误信息中建议的命令:

  git rebase --continue 

并且rebase会将您的固定文件和..continue。最有可能的是,它会运行到最后。



或者在同一个或另一个文件中遇到另一个冲突,您需要以类似的方式修复这个冲突,并继续,等等。



小心 - 每当 rebase 暂停时,可能会有许多文件冲突。 Git Status会将它们全部显示出来。此外,修复冲突时,请记住单个文件中可能存在许多冲突(文件各个部分中有许多标记)。



总结一下,命令行活动看起来像这:

 > (...)

> git status
(....)
#aha!我在readme.md
(...)

> vim readme.md#编辑,修复,保存
> git add readme.md#告诉Git那个文件现在好了
> git rebase --continue#告诉git重新开始工作

#现在可以,或者其他冲突 - 冲洗并重复,直到完成


I am new to git and I tried to squash my commits.

In my branch, it shows my 32 commits (John Smith), within that three commits of another two developers too (Prince Rolf and Harry).

For one commit a developer has amended.

Now if I try to squash all the commits I am getting an error:

error: could not apply ccdfa76... Add readme.md

I googled for the error, but was not able to find it.
I tried squashing by ten and then ten but that also throwing error.
Can you guys tell me how to swim it providing the error below?

$ git rebase -i aaaa

pick 04dc4d0 play: wip sports
pick f255d38 play: sports

解决方案

Your attempt to rebase with squash has not failed. What you see not an error.

Your rebase operation has been paused.

Read carefully the message:

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
Could not apply ccdfa7670a8eb780954edd1383e3378ef43292ac... Add readme.md

Look at the commands suggested. rebase / continue, rebase / skip, rebase / abort. This essentially tells you that the rebase is still ongoing. It is paused. You can ignore the problem and skip, you can do something and continue, or you can abort (and rollback) the rebase completely.

Ok. So we know what's the situation. Now, let's check WHY.
If you read the message, you know it's "cannot apply ccdfa(..)".

You could not check the status, index, etc, to see what's up, but you has not shown them. So, for now let's use what you gave us already.

If to read things really carefully, we can notice this note in the git log:

commit c0ad7755f58f1bef92d71b72b8e1397b9e07fdea
Merge: ccdfa76 b1ba9e4
Author: Prince Rolf
Date: Tue March 2 19:07:32 2017 -0500

Merge branch 'sports-module' of gitlab.cell.com:grp-imco-products/im-lap-sports into sports-module

# Conflicts:
# README.md

Look at the shouting "CONFLICTS". It's not a thing you often see in the commit message. That's commit c0ad77(..) (not the one we have problem with), but as you can see in its headers, this is a merge of the commit ccdfa76 (the one we have problem with) and b1ba9e4 (unknown so far).

Now look at the tree of commits, let's look for those commit IDs.

* 04dc4d0 play: wip sports
* c0ad775 Merge branch 'sports-module' of gitlab.paper.com:chain/catch-sports into sports-module
|\
| * b1ba9e4 play: sports
| * a2464b1 adding sports files
| * 1a3cc30 play: wip sports
* ccdfa76 (origin/master) Add readme.md

Hey, all of them happen to be at the very start of the history (bottom). Great. It will simplify looking at them.

That b1ba9e4 sits on top of a2464b1 which in turn sits on top of 1a3cc30 - and that's the rebase root you wrote in your rebase command.

c0ad775 is indeed a merge between the part that contains rebase-root and the ccdfa76 (problematic one) which is 'aside' the rest.

Now, let's look at the start of your rebase command:

git rebase -i 1a3cc30
pick ccdfa76 Add readme.md
squash a2464b1 adding sports files
squash b1ba9e4 play: sports
squash 04dc4d0 play: wip sports
squash f255d38 play: sports

Detailed command are not important right now. What's important is the effective sequence of commits that you requested:

0: 1a3cc30     \ (rebase root)
1: ccdfa76  ---:----- (problematic one)
2: a2464b1     |
3: b1ba9e4     /
-:(c0ad775)      (merge, not mentioned in rebase plan, so not requested)
4: 04dc4d0  ...
5: f255d38  ...

Looking at the commit tree, you try to inject the ccdfa76 (left side of tree) into the middle of right side of tree. Remember that the c0ad775 merge glued these two tree parts together and it had a conflict at 'readme' file. Remember that ccdfa76 message says adding readme file.

So now, apparently, the rebase has halted when trying to apply ccdfa76 onto 1a3cc30 with the same conflict at 'readme' file.

Apparently, ccdfa76 tries to add a readme file, but 1a3cc30 already has a readme file. Hence conflict.

That's my guess. Now let's get to the console.

Now start over, cleanup everything.
Do your rebase command with the same plan as before (pick/s/s/s/s/s.../s).
Wait until cannot apply ccdfa(..) shows up.
Remember that rebase is not faulted - it is paused so you can fix it and continue.
Now run git status and see what it says.

It should say something like:

git status
# On branch FOOBAR
# You have unmerged paths.
#   (fix conflicts and run "git commit")
#
# Unmerged paths:
#   (use "git add ..." to mark resolution)
#
# both added:      readme.md
#
no changes added to commit (use "git add" and/or "git commit -a")

Alright, so there's really conflict at this readme file. Now you can fix it. Open that file, find markers like

bum
<<<<<
bleh
=====
blah
>>>>>
whooo

This are merge conflicts markers. I wont explain how they work. Read about it online, or just use a merge tool of sorts (like i.e. KDiff3 or WinMerge or whatever).

The most important point is: edit the file and make sure it looks like you want it to look. When you end editing, there should be no markers inside.

When you finish fixing the conflict, run this to tell git that the conflicts in this file were all fixed:

git add readme.md

Yes. That's just plain old add. After that, use the command that was suggested in the "error message":

git rebase --continue

and the rebase will take your fixed file, and ..continue. Most probably, it will then run to the end.

Or will hit into another conflict in the same or another file, which you will need to fix in a similar way, and continue, and so on.

Be careful - whenever rebase pauses, there may be many files under conflict. Git Status will show them all. Also, when fixing conflicts, remember that there may be many conflicts in a single file (many markers in various parts of the file).

Summing up, commandline activity looks like this:

> git rebase -i 1a3cc30
(...)
error: cannot apply (..)

> git status
(....)
#aha! I see a conflict at "readme.md"
(...)

> vim readme.md            #edit, fix, save
> git add readme.md        # tell Git that file is OK now
> git rebase --continue    # tell git to get back to work

# now either it's ok, or another conflict - rinse and repeat until finished

这篇关于错误:无法应用---&gt;通过查看指令,以适当的方式尝试它,但仍然错误的git壁球的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆