0

so I want to remove everything that I have worked on today, both from the git repo and also my local.

i have a commit from yesterday, which I want to revert to. Could i remove the repo and then clone the repo from a specific commit?

thanks!

user2656127
  • 655
  • 3
  • 15
  • 31
  • Why don't you just call `git reset --hard ` ? – Roman Sep 26 '13 at 12:25
  • ... and then `git push -f`? (WARNING: this will lose later commits) – tom Sep 26 '13 at 12:26
  • If other developers have pulled the changes, see [Rolling back local and remote git repository by 1 commit](http://stackoverflow.com/questions/4647301/rolling-back-local-and-remote-git-repository-by-1-commit). – tom Sep 26 '13 at 12:32
  • and I want to lose the later commits, so that's good :) – user2656127 Sep 26 '13 at 12:33

1 Answers1

2

You can do reset to make changes to local repo and forcefully push to remote repo.

git reset --hard <commit>
git push --force <remote> <branch>

Warning: Reseting and forcefully pushing will delete the commit history.

Replace <commit>, <remote> and <branch> with the appropriate names like a SHA-hash, origin, and master respectively.

Here, <commit> is the SHA hash of the last commit upto which you wanna reset.

TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125