2

I've done a lot of changes in my local repo, including deleting thousands of files, and making hundreds of changes. Meanwhile, I did a filesync (just didn't have access to the internet) to a different computer, and then continue to create thousands of files, deleting thousands of files, and making hundreds of changes. Now the repo works fine since I updated it from the computer I worked on later, yet when I want to pull to my previous computer, this becomes a nightmare...apparently I'd have to manually checkout all the files I deleted or changed and revert to my last HEAD before pulling again...is there a simple super pull command to do just that? (just accept the remote repo as the super master)

I can just remove everything and do a git clone but since I have to then again install a lot of npm packages, it might take a while. Again, just by curiosity I'd like to know if there is a better way to do this then doing another git clone.

Aero Wang
  • 6,227
  • 9
  • 35
  • 70
  • doesn't `git reset --hard origin/master` work ? – Antwane Jul 26 '17 at 09:37
  • 1
    Possible duplicate of [Various ways to remove local Git changes](https://stackoverflow.com/questions/22620393/various-ways-to-remove-local-git-changes) – underscore_d Jul 26 '17 at 09:47
  • I generally advise avoiding `git pull` entirely. It gives people the wrong ideas. If you know how the two different Git commands that `git pull` runs for you work, you'd realize that you only want *one* of those two commands for this case (followed by a second command that's not in `git pull`'s options). – torek Jul 26 '17 at 12:45

1 Answers1

1

You can simply do:

git reset --hard <remote>/<branch>

to restore your local working folder to the version you had before doing any modifications, and then git pull should work fine.

Cristian Lupascu
  • 34,894
  • 15
  • 87
  • 127