1

I have a very hard to merge master changes to my feature branch. I just tried to merge master changes to my feature branch to test the code. I know there are files that have conflicts but I don't think I did it correctly.

I tried to run git pull and got the following error. When I run git checkout mybranch and says needs merge. error: you need to resolve your current index first Could you please guide me the correct approach? Thx

git pull
error: Pulling 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.
John
  • 169
  • 1
  • 3
  • 10
  • 1
    Possible duplicate of [Why does git say "Pull is not possible because you have unmerged files"?](https://stackoverflow.com/questions/26376832/why-does-git-say-pull-is-not-possible-because-you-have-unmerged-files) – phd Feb 03 '18 at 23:27

2 Answers2

2

Before doing your git pull command, it seems you have uncommitted or unstaged files on master. What a git status command say ?

If you have files to commit to master, commit them before changing the branch from master branch to your feature branch.

If you need to commit these files on the feature branch only, you can do :

git stash
git checkout my_feature_branch
git stash pop

Then, it will be easier to solve the conflicts for this branch.

cactuschibre
  • 1,908
  • 2
  • 18
  • 36
0

When you perform a git merge and have merge conflicts you must either fix them and commit or undo your merge with git merge --abort before you can pull again or checkout another branch.

Daniel
  • 10,641
  • 12
  • 47
  • 85