I am new to git. I have forked another repository awhile back. I wanted a fresh start so I grabbed my private clone and then added a remote for the upstream repository. I can't pull from the repository because it says some files are not uptodate. I don't care about these files, I want everything from the upstream remote. Is there a way I can quickly resolve this?
A:
Why not clone the upstream repository again, in another place on your local disk?
VonC
2009-09-30 19:30:23
+2
A:
To check out all files as they should be according to the repository, try either
git checkout -f
or
git reset --hard
Sometimes you may need to remove any untracked/ignored files which might conflict with things that have since been added upstream:
git clean -xdf
The -f
tells clean to go ahead and remove the files (since this can be dangerous!), the -x
tells it to delete ignored files too, and the -d
tells it to delete entire untracked directories as well. To see what it's going to remove, change the -f
to -n
, for dry run.
Jefromi
2009-09-30 19:34:12
I didn't know about git clean. Nice one. I upvoted you.
Vincent
2009-09-30 19:40:16
I've done everything above. I finally did a commit, pull and now I have 100 conflicts. It's a never ending cycle.
CountCet
2009-09-30 19:53:18
I'm a little confused now: do you also want to throw away the changes you've committed? If no, you have to deal with the conflicts. They are your problem, not git's. If yes, you can simply do `git reset --hard origin/master` to reset your current branch (master, hopefully) to origin/master. If you want to keep both, you could rename your current branch (`git branch -m master old_master`) and recreate master at origin/master (`git branch master origin/master`).
Jefromi
2009-09-30 20:05:14
I think the real problem is if the project I have forked has pushed changes and I try to pull them, they always show up as conflicts. I have to manually resolve ever file in the project if I wanted to pull.
CountCet
2009-09-30 22:36:27
A conflict doesn't occur without cause. It happens if you've modified the same thing, if a file is modified on one side and deleted on another... there is truly no way for git to know what to do in these cases.
Jefromi
2009-10-01 06:02:03