6

So I've used the following:

git checkout --orphan newBranch
git add -A  # Add all files and commit them
git commit
git branch -D master  # Deletes the master branch
git branch -m master  # Rename the current branch to master

Which works quite well for Gitrepo commit history, however, when I use gitk --all I still see all of the prior commits. Is it possible to also merge all of these commits into one as well?

Thanks!

Marlin Pierce
  • 9,931
  • 4
  • 30
  • 52
user3399101
  • 1,477
  • 3
  • 14
  • 29
  • 2
    Just delete the .git directory and initialize a new repo. – Damien Roche Jun 13 '14 at 16:43
  • how do i delete the .git directory? thanks – user3399101 Jun 13 '14 at 16:45
  • 3
    `rm -rf .git` should do it. See this answer here for more info: http://stackoverflow.com/questions/2006172/how-to-reset-a-remote-git-repository-to-remove-all-commits – Damien Roche Jun 13 '14 at 16:45
  • 2
    Are you familiar with `git rebase`? That won't be destructive like deleting your repo would be. – jakenberg Jun 13 '14 at 17:30
  • 1
    "when I use gitk --all" -- That's not fair. If you check before force-pushing and replacing the remote `master`, then yes, you will still have a local reference to what the remote looked like the last time you synced. –  Jun 13 '14 at 17:36

1 Answers1

3

Use git rebase -i --root. Then change the prefix of all lines except first from pick to squash. All commits will be merged in one single commit.

Of course, when you push your changes you'll need to force the push, otherwise it won't push your changes.

Andre Soares
  • 1,968
  • 3
  • 21
  • 24