0

i have 2 local (say A and B) and one remote repository. unfortunately i added a huge folder into A and pushed it. as i wanted to pull it into a third local repository C (my laptop), it was not feasible any more. then i wanted to undo the adding of the huge folder in A and tried a git filter-branch' command which terminated with error as the disc quota was exceeded. now, when i run du -h in A, it shows several ./.git-rewrite files, even if i checkout a commit before the addition of the huge file.

now - is there any way to undo the git filter-branch command? (my suspicion is that there is some alteration in the git history and i don't want to risk any damage) because then i would use Delete commits from a branch in Git to get rid of the folder and force the remote to forget it, too. as B is several commits behind, i would only use it as last option.

zuiop
  • 31
  • 4

1 Answers1

0

This is a great use for the reflog!

running git reflog will provide you with a list of amendments to your repository, something like the following:

8730047 (HEAD -> master) HEAD@{0}: filter-branch: rewrite
30b6014 (refs/original/refs/heads/master) HEAD@{1}: commit (initial): test
(END)

This top item here is the filter-branch command I've just run in my own repository. In order to undo it, I can run git reset --hard HEAD@{0} which will reset me back to my initial commit (titled test).

A McBride
  • 405
  • 3
  • 9