课程: Coding Exercises: GitHub

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Deleting all commit history

Deleting all commit history

(electronic sounds) - Git is such a fantastic tool. And it's a great idea to commit and push often because it's a great way to store changes to a project in the cloud. But occasionally I'd like to publish a branch on GitHub with a clean commit history. How would you delete all commit history of an existing branch on Git and GitHub? I'll give you a couple of seconds to pause the video and think about how you might solve something like this. (electronic sounds) Now here's what I would do. You can create, what's called an orphan branch. This is a branch that will have all the files in the current branch without any history. I'm going to start out by issuing a git checkout and use the orphan option here. And then I'm going to call this branch a clean branch. Now you'll need to add a commit to the files in the history. Notice that none of them have been added. So let's go ahead and do that. We'll say, git add -A, and then…

内容