Why does git say "Pull is not possible because you have unmerged files"? -
when seek pull in project directory in terminal, see next 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 not possible because have unmerged files. please, prepare them in work tree, , utilize 'git add/rm <file>' appropriate mark resolution, or utilize 'git commit -a'.
why git "pull not possible because have unmerged files"
, , how can resolve it?
what happening is, have set of files, have tried merging earlier, threw merge conflicts. ideally, if 1 gets merge conflict, should resolve them manually, , commit changes using git add together file.name && git commit -m "removed merge conflicts"
. now, user has updated files in question on repository, , has pushed changes mutual upstream repo.
it happens, merge conflicts (probably) lastly commit not not resolved, files not merged right, , hence u
(unmerged
) flag files. now, when git pull
, git throwing error, because have version of file, not correctly resolved.
to resolve this, have resolve merge conflicts in question, , add together , commit changes, before can git pull
.
# note: commands below in format `cuurent_working_directory $ command params` desktop $ cd test
first, allow create repository structure
test $ mkdir repo && cd repo && git init && touch file && git add together file && git commit -m "msg" repo $ cd .. && git clone repo repo_clone && cd repo_clone repo_clone $ echo "text2" >> file && git add together file && git commit -m "msg" && cd ../repo repo $ echo "text1" >> file && git add together file && git commit -m "msg" && cd ../repo_clone
now in repo_clone, , if git pull
, throw 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. /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; prepare conflicts , commit result.
if ignore conflicts in clone, , create more commits in original repo now,
repo_clone $ cd ../repo repo $ echo "text1" >> file && git add together file && git commit -m "msg" && cd ../repo_clone
and git pull
, get
repo_clone $ git pull u file pull not possible because have unmerged files. please, prepare them in work tree, , utilize 'git add/rm <file>' appropriate mark resolution, or utilize 'git commit -a'.
note file
in unmerged state , if git status
, can see same:
repo_clone $ git status on branch master branch , 'origin/master' have diverged, , have 1 , 1 different commit each, respectively. (use "git pull" merge remote branch yours) have unmerged paths. (fix conflicts , run "git commit") unmerged paths: (use "git add together <file>..." mark resolution) both modified: file
so, resolve this, first need resolve merge conflict ignored earlier
repo_clone $ vi file
and set contents to
text2 text1 text1
and add together , commit changes
repo_clone $ git add together file && git commit -m "resolved merge conflicts" [master 39c3ba1] resolved merge conflicts
git
No comments:
Post a Comment