【发布时间】:2017-11-25 18:24:15
【问题描述】:
我正在开发一个 Laravel 项目并使用 git-flow 来管理我的更改。我的 develop 分支是我最近完成的名为 feature/registration-captcha 的功能分支之前的两次提交。我想将此功能分支合并到开发分支中。
我最近提交的并入开发分支的提交只是运行composer update 来更新其中有错误的包。所以,composer.lock 文件当然已经被修改了。
feature/registration-captcha 功能分支包括向注册页面添加验证码包和验证码 UI。所以,这也修改了composer.lock文件。
当我坐在功能分支上时,我尝试从源树中合并提交,方法是选择 Repository > Git Flow > Finish Feature,然后在 Finish Feature 弹出:
然后我会收到以下消息:
这会产生一个composer.lock 文件,其中包含需要解决的合并冲突。我认为解决此问题的最佳方法是删除composer.lock 并通过运行composer update 或composer update --lock 创建一个全新的更新副本,添加未暂存的composer.lock 文件并提交更改。完成此操作后,我的提交如下所示:
当从命令行运行 git status 时,我会看到以下内容:
c:\my-project (HEAD detached at 2a9ff12)
λ git status
rebase in progress; onto 3070450
You are currently rebasing branch 'feature/registration-captcha' on '3070450'.
(all conflicts fixed: run "git rebase --continue")
nothing to commit, working directory clean
所以我认为正确的做法是运行git rebase --continue,之后我收到以下消息:
c:\my-project (HEAD detached at 2a9ff12)
λ git rebase --continue
Applying: add non captcha to registration page
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
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".
如果我再次运行 git status,我会看到与上次运行 git status 时相同的消息。
所以我现在想知道:
- 我应该在这里做什么来完成变基/合并?
- 我做错了吗?
- 我是否应该处理因更新包不同而可能引起的冲突?
任何帮助将不胜感激,谢谢!
【问题讨论】:
-
在这种情况下,您不应该删除 composer.lock 并进行作曲家更新 - 永远不要!合并冲突是有原因的。在您的方法中,您现在更新的软件包比您想要的要多得多。在这些情况下,最简单的方法是接受外国 composer.lock,丢弃你的版本。那么你需要记住你在你的分支中更新了哪些包(专业提示:为你的更新语句创建一个 git 提交并在评论中写下该语句)并显式运行 composer update
。有了专业提示,这一步可以自动化
标签: git version-control composer-php git-merge git-flow