tags:

views:

105

answers:

3

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?

+1  A: 
git checkout -f

After that you can do a

git pull
Vincent
A: 

Why not clone the upstream repository again, in another place on your local disk?

VonC
+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
I didn't know about git clean. Nice one. I upvoted you.
Vincent
I've done everything above. I finally did a commit, pull and now I have 100 conflicts. It's a never ending cycle.
CountCet
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
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
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