0

I am pretty new to git, so I wanted to know if there is any command which you could use if you just screw up everything on your local copy of a branch.

Something like:

git reclone
halfer
  • 19,824
  • 17
  • 99
  • 186
Jonas S.
  • 20
  • 4
  • Ok, i figured it out. It's just git revert. – Jonas S. Jul 23 '16 at 19:43
  • 2
    http://stackoverflow.com/questions/1146973/how-do-i-revert-all-local-changes-in-git-managed-project-to-previous-state?rq=1 – Jonas S. Jul 23 '16 at 19:44
  • Minor correction - `revert` undoes commits on a branch. If you want to throw away all local commits, you're better of with `reset --hard`. – halfer Jul 24 '16 at 16:44
  • (We don't use [solved] title amendments here btw - feel free to add an answer, or let this close as a dup of the specified question). – halfer Jul 24 '16 at 16:44

1 Answers1

2

You could reset your local branch to the remote using git reset:

$ git reset origin/master --hard
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Out of interest, does the `--hard` work at the end? I've always thought it would only work as a switch prior to the mandatory params (I always use `git reset --hard origin/master`). – halfer Jul 24 '16 at 16:49
  • 1
    @halfer yes it does – Mureinik Jul 24 '16 at 17:06