简体   繁体   English

更改GIT分支头,同时仍保持旧头和新头之间的提交

[英]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. 我在项目中创建了一个booboo,想恢复到先前的提交。 But I still would like to have my booboo files accessible for reference in the future. 但是我仍然希望以后可以访问我的booboo文件以供参考。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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