Search code examples
gitgit-clone

I have a messed git repository. How to clean it?


I have a git clone which is messed up with added new files, deleted files and both modified Files. I need a way to clean this up in a time saving manner.

Because of the conflicts in origin, When I pull the upstream it gives more than 2000 conficts. Can anyone tell me how to clean my origin and get the origin upto date with upstream ?


Solution

  • You could simply reset your own branch to the one from origin

    git fetch origin
    git reset --hard origin/aBranch
    

    That would remove any local commit and local modification from the working tree, and reset everything to what is fetched from the upstream repo.

    If "origin" and "upstream" differ, you would need to "git push --force" one to the other (make sure the other collaborators are aware of that push).