开发者

Start with a clean slate

Sometimes I start a project on github. I will make say around 100 commits and now I am ready to tweet about it. I want to have a clean commit history. So I delete the project and start a new project. Sometimes I would开发者_如何学运维 rollback all the previous commits and then will add one commit with final output.

How do I undo all the previous commits and then have just one commit with final output.


100 commits is great to start with! There's no reason to throw away that history and start over with a "clean" commit history. Your commit history will never stay clean, so there's no point in trying to clean it up now.

The only reason to go back and rewrite old commits is if you accidentally committed a password or some other secret into your code history. Otherwise, your project commit log reflects what actually happened, which is a good thing.


One way to do this, assuming that no one has already forked your repository (or you don't care if they have), is to git rebase -i and squash all commits back down a single commit.

Or you could do an export: Do a "git export" (like "svn export")?

Or you could rm -rf .git and then git init to get a new repo with the same files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜