Reputation: 10161
I want my git repo to be at the state it was at a specific commit. Once the repo is at the state, I want to be able to push to Github, making the remote be at that state. I know I can call git checkout <commit hash>
and my local repo will be at the state it was at the given commit, but it won't let you push.
I'm guessing that I should do something with git checkout
but I don't know what to do.
Thanks for any help on this simple question :)
Upvotes: 0
Views: 90
Reputation: 141598
You need to push with force since you are going to lose history.
git push -f origin master
This will forcefully push your changes. If you are trying to undo something, you may want to consider git revert
since it will allow you to keep history.
Upvotes: 3
Reputation: 301077
Use git reset --hard <commit>
to reset the repo to a particular commit.
This will make you lose your working directory changes and any commit after the commit
. You can still get back the newer commits from git reflog
and then using git reset
on those commits.
Also, if you had already pushed the other commits, you must avoid pushing to the remote without them.
Upvotes: 2