1

was working on a featurebranch (spun off from main) for some while, commited it and want to merge it back to main.

Unlike expected I get:

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 shows quite a lot of uncomitted files (which comes as a suprise to me to some extend) the entire message is here:

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

You can probably tell by now, that I am not too experienced with git (beyond the pure basics) and I am wondering how to proceed from here.

what catches my eye is mainly

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   step/step_server_env/prepare_step_server.yml

does that indicate this file might be where I have a conflict which I need to solve? I have compared them with ´git diff main..feature step/step_server_env/prepare_step_server.yml´ but can not make much sense of it in terms of where the actual conflict may lie

Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53
vrms
  • 217
  • 2
  • 8
  • You started one merge (perhaps by running `git pull`), left it incomplete, and are now trying to start *another* merge before you've finished the first one. Git won't let you do this, and unfortunately you may need to take a lot of care in terms of finishing or terminating the first one as this may mess with the state you *intend* to have (vs what you *will* have) as you begin the second one. – torek Oct 29 '21 at 18:07
  • 1
    Git is widely viewed (correctly, I think) as beginner-unfriendly: it has too many of these traps. For instance, cherry-pick is a form of merge, and rebase uses cherry-pick, so rebase is also a form of merge. When a merge stops in the middle, there are *some* warnings but they may have been lost in a sea of other messages. Once you're quite familiar with Git, these all stand out well enough, or make sense, or you know how to spot them, or whatever, but... well, it's problematic. My main recommendation here is: use `git status` often. – torek Oct 29 '21 at 18:10

1 Answers1

0

It seems you have one unsolved merge that you need to handle by yourself. The full message you posted in the link (and the highlighted part you posted in your question) says you need to manually resolve the conflict on file prepare_step_server.yml.

I advise you to look for an editor that has support for git diff - I like Intellij Idea or Visual Studio Code, both free (comunity) versions. It is helpful, but if you don't want them, you just need to open in any editor and fix the conflicting lines (you need to search the file for it, you will see some text markers showing the conflicting line you need to fix) and make a new commit. Maybe this tutorial or this other question can help you, if you are still lost...


EDIT:

Since you mentioned you like VIM, maybe this post might help you. It is about vimdiff, and how to use it as a merge tool. As a start you would need to make it your default merge tool doing the following:

git config merge.tool vimdiff
git config merge.conflictstyle diff3
git config mergetool.prompt false

Then you can just use the command git mergetool to open the editor's UI. It uses this terminology in the UI, in case you get lost with it:

LOCAL – this is file from the current branch

BASE – common ancestor, how file looked before both changes

REMOTE – file you are merging into your branch

MERGED – merge result, this is what gets saved in the repo

The post previously mentioned have more details on that - the user that made the question seemed kind of lost when trying to merge with it, and the accepted answer explains in details.

Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53
  • thx, I'll check that out. It seems I am still have trouble to really wrap a solid understanding around what a merge really does and everything else :-( – vrms Oct 29 '21 at 14:42
  • the tutorial you've linked is not so easily accessible (too difficult for me at least). However I found some wisdom that helped me with the understanding quite a bit in [this video](https://youtu.be/__cR7uPBOIk). Visual Studio Code does not in the setup I was running. Anyway it seems to be helpful generally. However I prefer to go the hard (vim) way for now. – vrms Nov 03 '21 at 05:59
  • I'm sorry the links I've posted didn't help. However, since you are using vim, I've added some information on how could you use it as a merge tool. I hope that helps you – Leonardo Alves Machado Nov 04 '21 at 16:13
  • thx @Leornardo. I'll dig into this more – vrms Nov 07 '21 at 07:50