1

I made some changes to the code, added, committed then pushed. This resulted in an error due to large files. Now I update .gitignore to track those large files.

How to push updated .gitignore only but leave out rest of the files that have been already commited??

Even after just adding and committing the updated gitignore file, when I push, it will push in the rest of the change sets that I have already previously committed but failed due to error.

henhen
  • 1,038
  • 3
  • 18
  • 36
  • 1
    Possible duplicate of [How to remove/delete a large file from commit history in Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – phd Nov 04 '19 at 11:21
  • https://stackoverflow.com/search?q=%5Bgit%5D+large+file+history – phd Nov 04 '19 at 11:21

1 Answers1

0

You need to remove the tracked files which are too large and that you just referenced in your .gitignore:

 git add .gitignore
 git rm large_file
 git commit -m "remove and ignore large file"
 git push

But if the error persists, that means the file history include past revisions which are too large and were not yet pushed.

In that case, you need to clean that file from the all history of your repository: see git filter-repo, which does replace BFG and git filter-branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250