简体   繁体   中英

Change GIT branch head while still keeping commits between old head and new head

I made a booboo in my project and would like to revert back to a previous commit. But I still would like to have my booboo files accessible for reference in the future. What should I do?

As long as your commits are reachable from a branch or tag, they'll never be garbage collected. The simplest thing would be to create a tag, eg

$ git tag mytag # optionally specify commit sha, default is HEAD
$ git reset --hard <new-sha>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM