![]() ![]() To get a good handle on what git reset does, I recommend reading this. It's common using it with a commit hash as you see above. Revert back without keeping the changes: git reset -hard Revert back with keeping the changes: git reset -soft Explanation: using git reset, you can reset to a specific state.To bring you back to that first empty commit. OK, going back to a previous commit in Git is quite easy. If you want to destroy the last commit and throw away any uncommitted changes, use a hard reset. Use git log -p to see changes, or git log -graph -all -oneline -decorate to see a compact tree. Then you can do something like % git reset ROOT Use git log to find the commit you want to the remote to be at. This will put an empty commit at the root of your history, and tag it with a tag named ROOT. If this is something you'll want to do often, I'd recommend that, immediately after git init, you run something like % git commit -allow-empty -allow-empty-message -m '' Unfortunately, as already explained, this approach does not delete all the history. (I hope that you realize that git push -f is a no-no whenever you're pushing to a repo that is shared with others.) ![]() If not, you'll also have to delete any other branches you have with git branch -d. (The above assumes that you have only one branch. depending on whether you want to preserve or discard all the changes made since that initial commit. To do that, you'd first find the SHA1 of the first commit, for example: % git rev-list -max-parents=0 -abbrev-commit HEAD The closest that I can get to what you're asking for would be to rollback all but the first commit. Learn more about Git generally in our guide Git vs SVN: Pros and Cons of Each Version Control System. It covers methods using both the revert and reset commands, and explains the differences. git directory of the local repo, and start over with git init. Git has the ability to revert the last commit, and this tutorial shows you exactly how. If I were you I'd just delete the remote repo and the. I don't know of any way to do exactly what you're asking (one can roll back to first commit, but not delete all history, since the history will at least contain that initial commit.) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |