3

I have updated files in my local instance and my git have 3 days old files. So i want to commit my changes for that i done following command to merge changes in git and my local instance

  1. Sudo git pull --> pulling files from git

So it will give some error like i have some updated files that are not in git , so i want to merge it or not.

2.sudo git stash --> moving my updated files to buffer (saving my changes in buffer)

3.sudo git pull --> pulling old files from git to my local instance again

  1. sudo git stash pop --> merging my local buffer files to local instance( i got old files from git now)

so i got following error

controller.php: needs merge
unable to refresh index

So now my entire local instance turned to set of old files, iam not able to merge my buffer changes to my local instance pls help

Alexis King
  • 40,717
  • 14
  • 119
  • 194
user3755198
  • 105
  • 1
  • 3
  • 8

1 Answers1

1

You can see a similar error message in "Git stash pop- needs merge, unable to refresh index".

In your case, you would need to resolve the merge (fixing merge conflicts) in order for the stash to proceed.

To reset a merged file, the OP used:

git reset HEAD -- filename
Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • i removed that merge messages from file and try to commit some other file so i got this error error: 'commit' is not possible because you have unmerged files.hint: Fix them up in the work tree, hint: and then use 'git add/rm ' as hint: appropriate to mark resolution and make a commit, hint: or use 'git commit -a'. fatal: Exiting because of an unresolved conflict. – user3755198 Jul 11 '14 at 08:46
  • @user3755198 what does `git status` returns? – VonC Jul 11 '14 at 08:47
  • @user3755198 that means you still have files with merge markers in it, that you need to remove. – VonC Jul 11 '14 at 08:48
  • is there any way to see what all files i have merged markers? – user3755198 Jul 11 '14 at 08:49
  • @user3755198 yes: `git status` See for instance https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line – VonC Jul 11 '14 at 08:49
  • it showing lots of modified files ,but i opened most of files and searched for "HEAD" or "< – user3755198 Jul 11 '14 at 08:52
  • @user3755198 does `git status` refers to "unmerged paths"? – VonC Jul 11 '14 at 09:41
  • got fixed temporarly just reset every new files – user3755198 Jul 11 '14 at 12:12
  • git reset HEAD file name – user3755198 Jul 11 '14 at 12:13
  • @user3755198 ok. I have included that in the answer for more visibility. – VonC Jul 11 '14 at 12:14
  • one more thing in one mac we are getting this error Pull is not possible because you have unmerged files. Please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution, or use 'git commit -a'. – user3755198 Jul 11 '14 at 12:14
  • @user3755198 you have more information about that in http://stackoverflow.com/a/15129293/6309 – VonC Jul 11 '14 at 12:17
  • can u tell me why am getting this conflict again and again ??? i even removed file and try to pull .But still it showing conflict??how is that possible ??i dont even have that file in my local instance? – user3755198 Jul 11 '14 at 12:23
  • @user3755198 in that case, check your `git config core.autocrlf` (http://stackoverflow.com/a/6335797/6309 and http://stackoverflow.com/q/11005688/6309) – VonC Jul 11 '14 at 12:26
  • @user3755198 simply fo on the Mac where you have the error on `git pull`, and type `git config core.autocrl`: if true, set it to false, and do a full reset. – VonC Jul 11 '14 at 12:28
  • is this answer worth it "You have to merge your files first. Do a git status to see what are the files that need to be merged (means you need to resolve the conflicts first). Once this is done, do git add file_merged and do your pull again" – user3755198 Jul 11 '14 at 12:31
  • @user3755198 yes, if there is a merge in progress, that is the way to proceed. But check your core.autocrlf first. – VonC Jul 11 '14 at 12:35
  • what is this core.autocrlf ? and what we expect from this check?? – user3755198 Jul 11 '14 at 12:42
  • @user3755198 re-read my previous comment http://stackoverflow.com/questions/24692872/git-command-error/24693450?noredirect=1#comment38298217_24693450 and its two associated links: a core.autocrlf is a git config which could explain why you have conflicts even though there seem to be no modification: it could be an eol (end-of-line) issue. – VonC Jul 11 '14 at 12:54