6

Context: Started project on GitHub and have been experimenting with git commands. The history of the project is untidy.

Question: How can I remove all history and replace all commit messages with something along the lines of "Uploaded initial version of project source"?

Lea Hayes
  • 62,536
  • 16
  • 62
  • 111

2 Answers2

8

This option will allow you to keep all your configuration files for the project
git reset --soft <sha_of_initial_commit>
git commit -a --amend -m "initial commit"

Andy
  • 44,610
  • 13
  • 70
  • 69
  • +1. Another use for `git reset --soft` added to the existing list: http://stackoverflow.com/questions/5203535/practical-uses-of-git-reset-soft – VonC Sep 15 '11 at 06:15
  • @Andy I have tried this and I get a long list of filenames with `create mode ...` Nothing appears to happen. I tried adding `git push` at the end of those commands, but still nothing. Am I missing something? thanks – Lea Hayes Sep 15 '11 at 18:03
  • 1
    You will get that long list as it is adding all the files back into your repo. What does the output of `git push -f` say? Did you check github and see if you got the results you wanted? – Andy Sep 15 '11 at 18:12
  • @Andy `push -f` worked perfectly. What does this do differently? – Lea Hayes Sep 15 '11 at 18:31
  • Since you re-wrote your history, `push` requires the `-f` flag to make sure that you know you are changing history. – Andy Sep 15 '11 at 18:45
3

Remove the .git directory.

git init
git add .
git commit -m "Initial commit"
git push origin master

Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406