Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git : Pull is not possible because you have unmerged files

Tags:

git

bitbucket

I am using php-git client to pull branches in my php script. and whenever i do checkout from master to testing i get following error.

error: Pull 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.

my files are on bitbucket server. and i add/modify files on bitbucket and commit there.

I dont understand , I dont mofify anything on my local machine, still i get this error.

Following is my 'git status' output.

Your branch is up-to-date with 'origin/testing'.

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

    modified:   g_1.0.yaml
    new file:   potter_3.4.yaml
    new file:   potter_3.4.yml

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   abc_1.0.json
like image 446
Nilesh Avatar asked Dec 08 '25 06:12

Nilesh


2 Answers

You are in the middle of a merge, try to read the messages you copied, it's pretty clear what you should do: You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge)

So first clear up the merge conflicts

use the merge tool of your choice (eg: tortoise merge, meld )
or do it by hand, in the conflicted file you should see arrows like <<<<<<< HEAD, select the appropriate one(s)

and then commit

git commit -m "foobar"

Now you should be able to push/pull from your remote, but you may need to pull first, to get the new changes merged locally.

Alternatively, if you don't need your code, and just want to toss out everything and get master, you can allays

git reset --hard origin/master

to reset your local repo to the state of origin/master, but you will loose all local changes

like image 73
MrKekson Avatar answered Dec 09 '25 23:12

MrKekson


If you don't want to merge changes and still want to update your locale, run:

git reset --hard HEAD 

This will reset your local with the head and then pull your remote using the git pull.

If you've already committed your merger locally (but haven't gone remote yet), and would like to return it again:

git reset --hard HEAD~1
like image 37
Md.Milton Avatar answered Dec 09 '25 23:12

Md.Milton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!