git - git '未合并的路径' - 需要解决策略
问题描述
在一个feature
分支(从 分拆main
)上工作了一段时间,提交它并希望将其合并回main
.
与预期不同,我得到:
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
git status 显示了很多未提交的文件(这在某种程度上让我感到惊讶)整个消息在这里:
user@hostname:~/path/to/repo> git merge feature_branch-2
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
user@hostname:~/path/to/repo>
user@hostname:~/path/to/repo> #################################################################################################
user@hostname:~/path/to/repo> #################################################################################################
user@hostname:~/path/to/repo>
user@hostname:~/path/to/repo> git status
On branch master
Your branch is up to date with 'origin/master'.
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
modified: .gitignore
new file: step/README.md
new file: step/postgres_install/README.md
new file: step/postgres_install/ansible.cfg
new file: step/postgres_install/defaults.yml
renamed: step/step_server_env/defaults_postgres.yml -> step/postgres_install/defaults_postgres.yml
new file: step/postgres_install/files/.alias
new file: step/postgres_install/files/.bashrc
new file: step/postgres_install/files/.editrc
new file: step/postgres_install/files/.forward
new file: step/postgres_install/files/.toprc
new file: step/postgres_install/files/backup_postgres.sh.9
new file: step/postgres_install/files/bin/.pg.env
new file: step/postgres_install/files/bin/client-postgres
new file: step/postgres_install/files/bin/postgresql.service
new file: step/postgres_install/files/bin/postgresql_rpm.service
new file: step/postgres_install/files/bin/start-postgres
new file: step/postgres_install/files/bin/status-postgres
new file: step/postgres_install/files/bin/stop-postgres
new file: step/postgres_install/files/bin/stop-postgres-immediate
new file: step/postgres_install/files/pg-rhel7-env.tar.gz
new file: step/postgres_install/files/pg_hba.conf
new file: step/postgres_install/files/postgresql.conf
new file: step/postgres_install/files/postgresql.conf.9.2
new file: step/postgres_install/files/scb_opensource_postgres.cfg
new file: step/postgres_install/inventory.yml
new file: step/postgres_install/postgres_install.yml
new file: step/postgres_install/postgres_install.yml.copy
new file: step/postgres_install/postgres_install_from_repo.yml
new file: step/postgres_install/sed-test.yml
deleted: step/step_server_env/.gitignore
modified: step/step_server_env/README.md
modified: step/step_server_env/ansibleSequence.sh
deleted: step/step_server_env/get_postgres_test.yml
modified: step/step_server_env/inventory.yml
new file: step/step_server_env/prepare_step_server_and_resize.yml
deleted: step/step_server_env/remove_parted.yml
modified: step/step_server_env/resize_vgsys-postgres.yml
modified: step/step_server_env/step_user_env.yml
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: step/step_server_env/prepare_step_server.yml
您现在可能已经知道,我对 git 的经验并不多(除了纯粹的基础知识),我想知道如何从这里开始。
吸引我眼球的主要是
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: step/step_server_env/prepare_step_server.yml
这是否表明该文件可能是我需要解决的冲突?我已经将它们与“git diff main..feature step/step_server_env/prepare_step_server.yml”进行了比较,但就实际冲突可能所在的位置而言,我无法理解
解决方案
看来您有一个未解决的合并需要自己处理。您在链接中发布的完整消息(以及您在问题中发布的突出显示部分)表示您需要手动解决文件冲突prepare_step_server.yml
。
我建议您寻找支持 git diff 的编辑器 - 我喜欢Intellij Idea 或Visual Studio Code,它们都是免费(社区)版本。这很有帮助,但如果你不想要它们,你只需要在任何编辑器中打开并修复冲突的行(你需要搜索文件,你会看到一些文本标记显示你需要修复的冲突行) 并进行新的提交。如果您仍然迷路,也许本教程或其他问题可以帮助您...
编辑:
既然你提到你喜欢 VIM,也许这篇文章可能会对你有所帮助。它是关于vimdiff,以及如何将它用作合并工具。首先,您需要将其设为您的默认合并工具,执行以下操作:
git config merge.tool vimdiff
git config merge.conflictstyle diff3
git config mergetool.prompt false
然后您可以使用该命令git mergetool
打开编辑器的 UI。它在 UI 中使用这个术语,以防你迷路:
LOCAL - 这是来自当前分支的文件
BASE - 共同祖先,文件在两次更改之前的样子
REMOTE - 您正在合并到您的分支的文件
MERGED - 合并结果,这是保存在 repo 中的内容
前面提到的帖子对此有更多详细信息 - 提出问题的用户在尝试与其合并时似乎有点迷失,并且接受的答案详细解释了。
推荐阅读
- notifications - 如何在代码中获取容器注册表 pubsub 通知(java 或任何其他语言)
- angular - 无法在 IIS 上部署 Angular 应用程序
- cassandra - cassandra 3.7 ReadCallback.java:126 - 超时;收到 2 个响应中的 1 个(包括数据)
- inno-setup - Inno Setup 匹配和替换文件中的确切字符串
- module - 如何在 Drupal 8 中创建一次性链接
- mysql - 以数字方式对包含时间的 varchar 字段进行排序
- mysql - 如何找到 DISTINCT 组合?
- python - 编辑字符串列表中的项目
- forms - 如何在 Drupal 8 中更改“注册用户”、“更改密码”和“用户编辑”页面
- excel - 使用条件计算动态范围内的单元格数