Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git conflict keep original upstream [duplicate]

Tags:

git

github

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?

like image 629
dibs_ab Avatar asked Jun 22 '26 16:06

dibs_ab


1 Answers

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.

like image 120
Jonathan Wakely Avatar answered Jun 24 '26 08:06

Jonathan Wakely