I currently have a local Git repository, which I push to a Github repository.
The local repository has ~10 commits, and the Github repository is a synchronised duplicate of this.
What I'd like to do is remove ALL the version history from the local Git repository, so the current contents of the repository appear as the only commit (and therefore older versions of files within the repository are not stored).
I'd then like to push these changes to Github.
I have investigated Git rebase, but this appears to be more suited to removing specific versions. Another potential solution is to delete the local repo, and create a new one - though this would probably create a lot of work!
ETA: There are specific directories / files that are untracked - if possible I would like to maintain the untracking of these files.
A more conceptual answer:
git automatically garbage collects old commits if no tags/branches/refs point to them. So you simply have to remove all tags/branches and create a new orphan commit, associated with any branch - by convention you would let the branch
master
point to that commit.The old, unreachable commits will then never again be seen by anyone unless they go digging with low-level git commands. If that is enough for you, I would just stop there and let the automatic GC do it's job whenever it wishes to. If you want to get rid of them right away, you can use
git gc
(possibly with--aggressive --prune=all
). For the remote git repository, there's no way for you to force that though, unless you have shell access to their file system.