0

I want to keep the local commit history as a teaching lesson for myself but remove them from the remote repository because of its embarrassing nature and glaring mistakes.

I know removing all but current commit on both ends can be done , but was wondering if its possible to keep the local history intact and have the remote repository's commit start from the current commit and then track the local commits as usual.

jar
  • 2,646
  • 1
  • 22
  • 47

1 Answers1

0

One option is to create a new branch to preserve the local history, rewrite history on the old branch and force push that. Then your local history is preserved while the remote history is overwritten.

# Assume you are currently on the master branch
git checkout -b archived_master
git checkout master
git reset --soft <sha_of_very_first_commit>
git commit --amend -m 'This is the commit for the new remote history'
git push -f
merlin2011
  • 71,677
  • 44
  • 195
  • 329