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