error: could not apply ---> tried it in proper way by seeing instructions but still errors for git squash
error: could not apply ---> tried it in proper way by seeing instructions but still errors for git squash
我是 git 的新手,我试图压缩我的提交。
在我的分支中,它显示了我的 32 个提交 (John Smith),在另外两个开发人员(Prince Rolf 和 Harry)的三个提交中。
开发人员修改了一个提交。
现在,如果我尝试压缩所有提交,我会收到错误消息:
错误:无法应用ccdfa76...添加readme.md
我用谷歌搜索了这个错误,但找不到。
我尝试按 10 压缩,然后再按 10 压缩,但这也引发了错误。
如果出现以下错误,你们能告诉我如何游泳吗?
$git rebase -i aaaa
pick 04dc4d0 play: wip sports
pick f255d38 play: sports
您尝试 rebase
与 squash
没有失败。你看到的不是错误。
您的变基操作已暂停。
仔细阅读留言:
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
查看建议的命令。 rebase / continue
、rebase / skip
、rebase
/ abort
。这基本上告诉你 rebase 仍在进行中。它被暂停了。你可以忽略这个问题并跳过,你可以做一些事情然后继续,或者你可以完全中止(并回滚)rebase。
好的。所以我们知道情况如何。现在,让我们检查一下原因。
如果您阅读该消息,就会知道它是 "cannot apply ccdfa(..)"。
您无法检查状态、索引等以了解发生了什么,但您没有显示它们。所以,现在让我们使用你已经给我们的东西。
如果真的仔细阅读,我们可以在 git 日志中注意到这条注释:
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
看呐喊"CONFLICTS"。这不是您经常在提交消息中看到的东西。那是提交 c0ad77(..)
(不是我们遇到的问题),但正如您在其 headers 中看到的那样,这是提交 ccdfa76
(我们遇到问题的那个)的合并和 b1ba9e4
(目前未知)。
现在查看提交树,让我们查找那些提交 ID。
* 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
嘿,他们都恰好在历史的最开始(下)。伟大的。它将简化对它们的查看。
b1ba9e4
位于 a2464b1
之上,而 a2464b1
又位于 1a3cc30
之上 - 这就是您在变基命令中编写的变基根。
c0ad775
确实是包含 rebase-root 的部分和 ccdfa76
(有问题的部分)之间的合并,后者是 'aside' 其余部分。
现在,让我们看看 rebase 命令的开头:
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
详细命令现在不重要。重要的是您请求的有效提交顺序:
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 ...
查看提交树,您尝试将 ccdfa76
(树的左侧)注入到树右侧的中间。请记住,c0ad775 merge
将这两个树部分粘合在一起,它在 'readme' 文件中有一个 冲突 。请记住 ccdfa76
消息说 adding readme file
.
所以现在,显然,当尝试将 ccdfa76
应用到 1a3cc30
时,与 相同的冲突 在 'readme' 文件中,变基已经停止.
显然,ccdfa76
试图添加一个 readme
文件,但是 1a3cc30
已经有一个自述文件。因此冲突。
这是我的猜测。现在让我们进入控制台。
现在重新开始,清理一切。
使用与以前相同的计划执行 rebase 命令 (pick/s/s/s/s/s.../s).
等到 cannot apply ccdfa(..)
出现。
请记住,rebase 没有错误 - 它已暂停,因此您可以修复它并继续。
现在 运行 git status
看看它说了什么。
应该这样写:
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")
好吧,这个自述文件确实存在冲突。现在你可以修复它了。打开那个文件,找到像
这样的标记
bum
<<<<<
bleh
=====
blah
>>>>>
whooo
这是合并冲突标记。我不会解释它们是如何工作的。在线阅读它,或者只是使用各种合并工具(例如 KDiff3 或 WinMerge 或其他)。
最重要的一点是:编辑文件并确保它看起来像您想要的样子。当你结束编辑时,里面应该没有标记。
当您完成冲突修复后,运行 告诉 git 此文件中的冲突已全部修复:
git add readme.md
是的。那只是普通的旧 add
。之后,使用 "error message":
中建议的命令
git rebase --continue
rebase 将获取您的固定文件,然后..继续。很可能,它将 运行 结束。
或者会在同一个或另一个文件中遇到另一个冲突,您需要以类似的方式修复,然后继续,依此类推。
小心 - 每当 rebase
暂停时,可能会有 许多 文件处于冲突状态。 Git Status 会显示全部。此外,在修复冲突时,请记住,单个文件中可能存在许多冲突(文件各个部分的许多标记)。
总结起来,命令行 activity 看起来像这样:
> 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
我是 git 的新手,我试图压缩我的提交。
在我的分支中,它显示了我的 32 个提交 (John Smith),在另外两个开发人员(Prince Rolf 和 Harry)的三个提交中。
开发人员修改了一个提交。
现在,如果我尝试压缩所有提交,我会收到错误消息:
错误:无法应用ccdfa76...添加readme.md
我用谷歌搜索了这个错误,但找不到。
我尝试按 10 压缩,然后再按 10 压缩,但这也引发了错误。
如果出现以下错误,你们能告诉我如何游泳吗?
$git rebase -i aaaa
pick 04dc4d0 play: wip sports
pick f255d38 play: sports
您尝试 rebase
与 squash
没有失败。你看到的不是错误。
您的变基操作已暂停。
仔细阅读留言:
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
查看建议的命令。 rebase / continue
、rebase / skip
、rebase
/ abort
。这基本上告诉你 rebase 仍在进行中。它被暂停了。你可以忽略这个问题并跳过,你可以做一些事情然后继续,或者你可以完全中止(并回滚)rebase。
好的。所以我们知道情况如何。现在,让我们检查一下原因。
如果您阅读该消息,就会知道它是 "cannot apply ccdfa(..)"。
您无法检查状态、索引等以了解发生了什么,但您没有显示它们。所以,现在让我们使用你已经给我们的东西。
如果真的仔细阅读,我们可以在 git 日志中注意到这条注释:
commit c0ad7755f58f1bef92d71b72b8e1397b9e07fdea
Merge: ccdfa76 b1ba9e4
Author: Prince Rolf
Date: Tue March 2 19:07:32 2017 -0500Merge branch 'sports-module' of gitlab.cell.com:grp-imco-products/im-lap-sports into sports-module
# Conflicts:
# README.md
看呐喊"CONFLICTS"。这不是您经常在提交消息中看到的东西。那是提交 c0ad77(..)
(不是我们遇到的问题),但正如您在其 headers 中看到的那样,这是提交 ccdfa76
(我们遇到问题的那个)的合并和 b1ba9e4
(目前未知)。
现在查看提交树,让我们查找那些提交 ID。
* 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
嘿,他们都恰好在历史的最开始(下)。伟大的。它将简化对它们的查看。
b1ba9e4
位于 a2464b1
之上,而 a2464b1
又位于 1a3cc30
之上 - 这就是您在变基命令中编写的变基根。
c0ad775
确实是包含 rebase-root 的部分和 ccdfa76
(有问题的部分)之间的合并,后者是 'aside' 其余部分。
现在,让我们看看 rebase 命令的开头:
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
详细命令现在不重要。重要的是您请求的有效提交顺序:
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 ...
查看提交树,您尝试将 ccdfa76
(树的左侧)注入到树右侧的中间。请记住,c0ad775 merge
将这两个树部分粘合在一起,它在 'readme' 文件中有一个 冲突 。请记住 ccdfa76
消息说 adding readme file
.
所以现在,显然,当尝试将 ccdfa76
应用到 1a3cc30
时,与 相同的冲突 在 'readme' 文件中,变基已经停止.
显然,ccdfa76
试图添加一个 readme
文件,但是 1a3cc30
已经有一个自述文件。因此冲突。
这是我的猜测。现在让我们进入控制台。
现在重新开始,清理一切。
使用与以前相同的计划执行 rebase 命令 (pick/s/s/s/s/s.../s).
等到 cannot apply ccdfa(..)
出现。
请记住,rebase 没有错误 - 它已暂停,因此您可以修复它并继续。
现在 运行 git status
看看它说了什么。
应该这样写:
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")
好吧,这个自述文件确实存在冲突。现在你可以修复它了。打开那个文件,找到像
这样的标记bum
<<<<<
bleh
=====
blah
>>>>>
whooo
这是合并冲突标记。我不会解释它们是如何工作的。在线阅读它,或者只是使用各种合并工具(例如 KDiff3 或 WinMerge 或其他)。
最重要的一点是:编辑文件并确保它看起来像您想要的样子。当你结束编辑时,里面应该没有标记。
当您完成冲突修复后,运行 告诉 git 此文件中的冲突已全部修复:
git add readme.md
是的。那只是普通的旧 add
。之后,使用 "error message":
git rebase --continue
rebase 将获取您的固定文件,然后..继续。很可能,它将 运行 结束。
或者会在同一个或另一个文件中遇到另一个冲突,您需要以类似的方式修复,然后继续,依此类推。
小心 - 每当 rebase
暂停时,可能会有 许多 文件处于冲突状态。 Git Status 会显示全部。此外,在修复冲突时,请记住,单个文件中可能存在许多冲突(文件各个部分的许多标记)。
总结起来,命令行 activity 看起来像这样:
> 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