-1

I commited and pushed binary file to git repo. Actually I don't wan't this file in git repo, I was needed to add it to LFS.

So, firstly question is - how to exclude this file from remote git tracking?

Sirop4ik
  • 4,543
  • 2
  • 54
  • 121

1 Answers1

2
  1. Add it to your .gitignore file and don't forget to commit the file :-)

    • You can use this site: http://gtiignore.io to generate the .gitignore for you and add the required path to your binary files/folder(s)
  2. Once you added the file to .gitignore you can remove the "old" binary file with BFG.

Important:

Since the file is already tracked by git, unless you will remove it from history (ex. BFG) you need to remove it manually and commit your changes.


How to remove big files from the repository

You can use git filter-branch or BFG. https://rtyley.github.io/bfg-repo-cleaner/

BFG Repo-Cleaner

an alternative to git-filter-branch.

The BFG is a simpler, faster alternative to git-filter-branch for cleansing bad data out of your Git repository history:

* Removing Crazy Big Files*
* Removing Passwords, Credentials & other Private data

Examples (from the official site)

In all these examples bfg is an alias for java -jar bfg.jar.

# Delete all files named 'id_rsa' or 'id_dsa' :
bfg --delete-files id_{dsa,rsa}  my-repo.git

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167