Why does git say, “Pulling out is impossible because you have unmixed files”?

When I try to pull the project directory into the terminal, I see the following error:

harsukh@harsukh-desktop:~/Sites/branch1$ git pull origin master U app/config/app.php U app/config/database.php U app/routes.php Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'. 

Why does git say "Pull is not possible because you have unmerged files" and how to resolve it?

+137
git git-pull git-fetch merge-conflict-resolution
Oct. 15 '14 at 7:28
source share
10 answers

What is currently happening is that you have a certain set of files that you tried to merge earlier, but they launched merge conflicts. Ideally, if a merge conflict occurs, he should resolve them manually and commit the changes using git add file.name && git commit -m "removed merge conflicts" . Now another user has updated the files in question in his repository and made his changes to the general upstream repository.

It so happened that your merging conflicts (possibly) of the last commit were not resolved, so your files are not combined in order and, therefore, the U ( unmerged ) flag for files. So, now when you do git pull , git throws an error because you have some version of the file that is not resolved correctly.

To solve this problem, you will have to resolve the merge conflicts in question and add and commit the changes before you can do git pull .

An example of reproducing and resolving a problem:

 # Note: commands below in format `CUURENT_WORKING_DIRECTORY $ command params` Desktop $ cd test 

First, create a repository structure

 test $ mkdir repo && cd repo && git init && touch file && git add file && git commit -m "msg" repo $ cd .. && git clone repo repo_clone && cd repo_clone repo_clone $ echo "text2" >> file && git add file && git commit -m "msg" && cd ../repo repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone 

Now we are in repo_clone, and if you do git pull , it will cause conflicts

 repo_clone $ git pull origin master remote: Counting objects: 5, done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From /home/anshulgoyal/Desktop/test/test/repo * branch master -> FETCH_HEAD 24d5b2e..1a1aa70 master -> origin/master Auto-merging file CONFLICT (content): Merge conflict in file Automatic merge failed; fix conflicts and then commit the result. 

If we ignore conflicts in the clone and make more commits in the original repo,

 repo_clone $ cd ../repo repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone 

And then we do git pull , we get

 repo_clone $ git pull U file Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm <file>' as appropriate to mark resolution, or use 'git commit -a'. 

Note that file now in an unrelated state, and if we do a git status , we can clearly see the same thing:

 repo_clone $ git status On branch master Your branch and 'origin/master' have diverged, and have 1 and 1 different commit each, respectively. (use "git pull" to merge the remote branch into yours) You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add <file>..." to mark resolution) both modified: file 

So, to solve this problem, you first need to resolve the merge conflict, which we ignored earlier

 repo_clone $ vi file 

and set its contents to

 text2 text1 text1 

and then add it and commit the changes

 repo_clone $ git add file && git commit -m "resolved merge conflicts" [master 39c3ba1] resolved merge conflicts 
+175
Nov 28 '14 at 10:51
source share

You are trying to add another new entry to your local branch until the working directory is clean. As a result, Git refuses to do attraction. For a better visualization of the scenario, consider the following diagrams:

remote: A <-B <-C <-D
local: A <-B *
(* indicates that you have several files that have been modified but not committed.)

There are two options for solving this situation. You can either discard the changes in your files or save them.

Option One: Throw Changes
You can use git checkout for each unrelated file, or you can use git reset --hard HEAD to reset all files in your branch in HEAD. By the way, HEAD is at your local B branch, without an asterisk. If you select this option, the chart will be as follows:

remote: A <-B <-C <-D
local: A <-B

Now that you are pulling, you can redirect your branch with the changes from the master. After you pull, the branch will look like master:

local: A <-B <-C <-D

Option Two: Save Changes
If you want to save changes, you will first want to resolve any merge conflicts in each of the files. You can open each file in your IDE and search for the following characters:

<<<<<<<<HEAD
// your version of the code
=======

// remote code version
→ → →>

Git presents you two versions of the code. The code contained in the HEAD brand is a version from the current local branch. Another version is what comes from the remote. After you have selected the version of the code (and deleted the other code along with the markers), you can add each file to your staging area by typing git add . The final step is to commit your result by typing git commit -m with the appropriate message. At this point, our chart looks like this:

remote: A <-B <-C <-D
local: A <-B <-C '

Here I denoted the commit that we just made as C ', because it is different from committing C on the remote. Now, if you try to pull, you will get an immediate error ahead. Git cannot reproduce the changes in the remote area on your branch, because both your branch and the remote part are separated from the general ancestral commit B. At this point, if you want to pull, you can either make another git merge or git rebase your branch on the remote control.

Git mastery requires the ability to understand and manipulate unidirectional linked lists. I hope this explanation makes you think in the right direction about using Git.

+34
Dec 01 '14 at 9:26
source share

Theres a simple solution. But for this you first need to study the following

 vimdiff 

To remove conflicts, you can use

 git mergetool 

The above command basically opens a local file, a mixed file, a deleted file (3 files in total) for each conflicting file. Local and remote files are for reference only, and with their help you can choose what to include (or not) in the mixed file. And just save and close the file.

+25
Dec 03 '14 at 19:04
source share

If you want to remove the remote branch to run locally (say, for verification or testing), and when you $ git pull get local merge conflicts:

 $ git checkout REMOTE-BRANCH $ git pull (you get local merge conflicts) $ git reset --hard HEAD (discards local conflicts, and resets to remote branch HEAD) $ git pull (now get remote branch updates without local conflicts) 
+6
Aug 03 '16 at 15:50
source share

You have local files that need to be merged before you can pull. You can check files and then pull to overwrite local files.

 git checkout app/config/app.php app/config/database.php app/routes.php git pull origin master 
+5
Oct. 15 '14 at 7:32
source share

If you do not want to merge the changes and still want to update the local version, do:

 git reset HEAD --hard 

This will reset your local level using HEAD and then pull out your remote with git pull.

If you have already committed the merge locally (but have not yet sent it to the remote device) and want to cancel it as well:

 git reset --hard HEAD~1 
+4
Jul 11 '16 at 12:51 on
source share

I had the same problem
In my case, the following steps:

  • The entire file that starts with the U (unmerged) character has been deleted. as-



 U project/app/pages/file1/file.ts U project/www/assets/file1/file-name.html 
  1. Pull the code from the wizard


 $ git pull origin master 
  1. Checked Status


  $ git status 

Here is the message that appeared -
and have respectively 2 and 1 different fixations, respectively.
(use "git pull" to merge the remote branch into yours)
You have indelible paths.
(fix conflicts and run "git commit")

Fixed ways:
(use "git add ..." to mark permission)

 both modified: project/app/pages/file1/file.ts both modified: project/www/assets/file1/file-name.html 
  1. All new changes added -


  $ git add project/app/pages/file1/file.ts project/www/assets/file1/file-name.html 
  1. Commit changes to the head -


 $ git commit -am "resolved conflict of the app." 
  1. Popped the code -


 $ git push origin master 

Which twist can solve the problem with this image - enter image description here

+1
May 10 '17 at 7:30 a.m.
source share

If a merge conflict occurs, you can open a separate file. You will get the characters "<<<<<or → → →>". They relate to your changes and changes present on the remote control. You can manually edit the desired part. after that save the file and then run: git add

Merge conflicts will be resolved.

0
Feb 11 '16 at 9:44
source share

Just run this command:

 git reset --hard 
-one
Mar 14 '18 at 11:25
source share



All Articles