0

How can I remove the first git commit from the history? I just want the tree to start with the second commit. I know git rebase -i <sha1_of_commit> but this doesn't work for the first commit.

Repository is not shared with anyone.

amorfis
  • 15,390
  • 15
  • 77
  • 125

1 Answers1

1

If you still didn't published your repo, you can use git filter-branch. Just bear in mind that technically this create new repository, unconnected with the old one (hence the "if you didn't published it yet" rule).

git filter-branch --commit-filter '
    if [ "$GIT_COMMIT" = "full ID/SHA of the commit you want to skip here" ];
    then
            skip_commit "$@";
    else
            git commit-tree "$@";
    fi' HEAD
anydot
  • 1,499
  • 9
  • 14