0

I am working to move a git repo from one provider to another. As part of that process the new repo is being rejected on push due to the size of a file in the history (file was removed months ago but still exists in history).

I found both git filter-branch and BFG repo-cleaner as options to correct this. They work as expected and allow me to push to the new repo but I am finding any ref with the signature task/my-branch get duplicated to Task/my-branch and I cannot find any reference that would explain why or how to avoid this. Worst case scenario I can clean these manually after the move but would like to understand better why its happening and if there is a way to prevent it.

steps taken with BFG cleaner

1) git clone --bare ssh://path/to/repo.git

2) cd repo.git

3) git branch -a

observe branches such as task/my-branch

4) cd ..

5) java -jar bfg.jar --delete-files repo.git

6) git reflog expire --expire=now --all && git gc --prune=now --aggressive

7) git branch -a

observe branches such as task/my-branch AND Task/my-branch

similar process with git filter-branch

1) git clone --bare ssh://path/to/repo.git

2) cd repo.git

3) git branch -a

observe branches such as task/my-branch

4) git filter-branch -f --prune-empty --tag-name-filter cat --tree-filter 'rm -f -- --all

5) git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d

6) git reflog expire --expire=now --all && git gc --prune=now --aggressive

7) git branch -a

observe branches such as task/my-branch AND Task/my-branch

  • I cannot speak to BFG, but in Git, you might get this if you are performing your `filter-branch` on a Windows or MacOS system and one of your branches is named `Task/`. This results in Git creating a directory named `Task` and from then on, every time it tries to create a directory named `task` (lowercase) to hold, e.g., `task/my-branch`, it winds up re-using the existing `Task`, i.e., a branch now named `Task/my-branch`. The cure is to do this on Linux or equivalent. – torek Sep 10 '18 at 21:31
  • ok that actually makes sense... and I do have a few branches that were misnamed `Task` instead of `task` .... I will check with my team and see if those branches can be removed and try the process again. Thank you – Neil Larson Sep 10 '18 at 21:38
  • Renaming or deleting those branches should help too. The general rule for case-folding systems (Windows and MacOS) is to just avoid things that differ only in case (file names, branch names, etc) so as to sidestep the whole issue. – torek Sep 10 '18 at 21:44
  • @torek thanks so much for this. it didnt even occur to me it could be the OS ... this has indeed resolved the issue. I very much appreciate your offering up the thoughts – Neil Larson Sep 10 '18 at 22:10

0 Answers0