2

I am using visual studio for C++ and I have forked a repo and during building,git tracked this huge file of 101MB which resides in src/.vs/v15/ipch

Now the problem is I cannot push any of my changes to the origin as GitHub's size limit is 100MB.

I committed 4-5 changes after this and cannot push a single of them to the origin.

Following is the error i get in bash:

remote: error :GH001:

remote: error :GH001

I tried doing this :

git --rm cached <file>

This deleted my files from index but I still have to push those changes.

How can I deal with this issue?

curious
  • 1,504
  • 5
  • 18
  • 32
1.618
  • 339
  • 2
  • 14
  • 2
    You should put the entire `.vs` directory in your `.gitignore` file, you never want to check it in as it is generated every time anyway. If you don't need the individual changes, copy the files you have changed elsewhere, delete and reclone the repo, then put the files back once you have a proper .gitignore file setup and commit and push them. https://github.com/github/gitignore/blob/master/VisualStudio.gitignore – Retired Ninja Aug 20 '17 at 04:51
  • Thanks @RetiredNinja. Is there a way to go make n commits and undo tracking of .vs code when I changed it? kind of like rebase or something? I really do not wish to delete the repo as I have spent lot of time in setting up the configuration files – 1.618 Aug 20 '17 at 04:57
  • @Nexus https://stackoverflow.com/search?q=%5Bgit%5D+remove+directory+from+history – phd Aug 20 '17 at 11:16

1 Answers1

1

Is there a way to go make n commits and undo tracking of .vs code when I changed it?

You can try BFG Repo-Cleaner in order to clean your local repo of that big file, but it applies only on a bare repo.

For you current local (non-bare) repo, you can follow "Removing sensitive data from a repository" and remove that one specific file from all your past commits.

git filter-branch --force --index-filter \
  'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
  --prune-empty --tag-name-filter cat -- --all

But actually, you should remove the .vs folder itself: see "Remove folder and its contents from git/GitHub's history"

git filter-branch --tree-filter 'rm -rf src/.vs' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo .vs/ >> .gitignore
git add .gitignore
git commit -m 'Removing src/.vs from git history'
git gc
git push origin master --force
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250