0

What do I need to enter in command line if I want to fully restore my local git repository with a specific remote repository that is not the latest? I do not want to sync/merge files but rather get old files back and delete ones that were created after the commit to which I am looking to revert.

Sandeep Garg
  • 1,292
  • 1
  • 13
  • 31
MA1
  • 33
  • 6
  • Possible duplicate of [git: sync local repo with remote one](https://stackoverflow.com/questions/6373277/git-sync-local-repo-with-remote-one) – phd Jun 26 '18 at 17:58

1 Answers1

3

If you want to set your repository to a previous state, find one first :

git log

Find the commit you want to revert to (the commit it, something like 30cb7e27aead5ade0a8048e2459cbda63697bbac)

The issue this command :

git reset --hard <commit-id>

If you messed up, you can revert it like the previous command like this:

git reset --hard HEAD@1

Please notice this will remove any uncommited diffs from your worktree. Commit or stash everything before if you want to keep them.

blue112
  • 52,634
  • 3
  • 45
  • 54
  • 1
    This can be done in one command like `git reset --hard origin/master` (or whatever other remote and/or branch). – aragaer Jun 27 '18 at 06:37