3

I made a copy of a repo from github. Was just playing around the code a bit, made a branch committed that changes locally and now the original code is updated,so I want to delete whatever I did to my fork and get changes made by the upstream.

I get a conflict if I do

git fetch upstream
git merge upstream/master
#Automatic merge failed; fix conflicts and then commit the result.

and gives in two file names showing few changes which I never did.

So I did a git status which gives me a new filename(which I never made but was made by my upstream) and Unmerged paths:

#   (use "git add/rm <file>..." as appropriate to mark resolution)

for two files.

I want all the new changes and destroy mine. What could possibly be the solution and why does GIT wants me to add a file I never made?

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
dibs_ab
  • 723
  • 2
  • 13
  • 24
  • so you want me to do something like git fetch orgin and then git reset --hard origin/master? where would I get changes from upstream in this scenario? – dibs_ab Feb 13 '13 at 11:44
  • I still get the same conflict message after I do what is suggested in the link you mentioned. – dibs_ab Feb 13 '13 at 11:46

1 Answers1

4

Abort the conflicted merge:

git merge --abort

then set your local repo to the same commit as upstream, discarding local changes:

git reset --hard upstream/master

As for your question:

why does GIT wants me to add a file I never made?

It doesn't. It's telling you to resolve the conflicts in the files you changed, then git add <file> on those files, to mark the edited versions as resolved and OK to commit.

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521