If you have a trouble with your bare git repository or just for purge history: (and if you have the same problems with clone) git gc --auto error: Could not read 3540c4efdad96dbf22d45b94c1c32913621458a1 fatal: Failed to traverse parents of commit da1932ecde5950496904179e77b2635ca4103ba9 error: failed to run repack Find the last good commit at the end before error: git rev-list HEAD Purging history before this commit (in clone repository): Let's say $drop is the hash of the latest commit you want to drop. To keep things sane and simple, make sure the first commit you want to keep, ie. the child of $drop, is not a merge commit. Then you can use: git filter-branch --parent-filter "sed -e 's/-p $drop//'" \ --tag-name-filter cat -- \ --all ^$drop The above rewrites the parents of all commits that come "after" $drop. Then, to clean out all the old cruft. First, the backup references from filter-branch: git for-each-ref --format='%(refname)' refs/original | \ while read ref do git update-ref -d "$ref" done Then clean your reflogs: git reflog expire --expire=0 --all And finally, repack and drop all the old unreachable objects: git repack -ad git prune # For objects that repack -ad might have left around Rebuild your bare git repository : (applies Doliforge but can be applied to any repository) First you need to be sure that /var/lib/codendi/gitolite/admin/ is clean: - stop the platform (http and cron). - go in /var/lib/codendi/gitolite/admin/ directory and run, as codendiadm "git gc --auto" - If everything is ok, then (WARNING: do not continue if there are any errors) - go in /var/lib/codendi/gitolite/repositories/ - mv gitolite-admin.git gitolite-admin.git-backup - git clone --bare /var/lib/codendi/gitolite/admin gitolite-admin.git - chown gitolite:gitolite -R gitolite-admin.git - chmod 0770 gitolite-admin.git - cp -a gitolite-admin.git-backup/gl-conf gitolite-admin.git - cp -a gitolite-admin.git-backup/index gitolite-admin.git - cp -a gitolite-admin.git-backup/hooks/* gitolite-admin.git/hooks ------------------------------------------------------------------------------------ Other solution, but not tested with Tuleap: Find the first and the last good commit git rev-list HEAD [--reverse] In the master branch, position on the HEAD in the last good commit : git checkout Create a branch with this commit : git checkout -b Create an empty branch from this temporary branch git checkout --orphan With "git status" you will see the file at the time of last good commit, You can commit this files as if it were a first commit: git commit -m "First commit" After this, you can create a bash outside the repository with this code : --------------------- #!/bin/sh cd git_directory git checkout for commit in $(git rev-list master --reverse ..); do git cherry-pick $commit done -------------------- it will make a cherry-pick all the commits starting from the last good commit (before error) in the first commit (last date) After this you can delete the original "master" branch and rename in "master" Ideally you can transfer the master branch in another repository to the household in the index: # Just setting variables on top for clarity. # Set this to the path to your original repository. ORIGINAL_REPO=/path/to/original/repository # Create a new repository… mkdir fun cd fun git init # …and add an initial empty commit to it git commit --allow-empty -m "The first evil." # Add the original repository as a remote git remote add previous $ORIGINAL_REPO git fetch previous # Get the hash for the first commit in the original repository FIRST=`git log previous/master --pretty=format:%H --reverse | head -1` # Cherry-pick it git cherry-pick $FIRST # Then rebase the remainder of the original branch on top of the newly # cherry-picked, previously first commit, which is happily the second # on this branch, right after the empty one. git rebase --onto master master previous/master # rebase --onto leaves your head detached, I don't really know why) # So now you overwrite your master branch with the newly rebased tree. # You're now kinda done. git branch -f master git checkout master # But do clean up: remove the remote, you don't need it anymore git remote rm previous