I backed up my database to GIT just so I could get the db at my home computer.
I don't want this file to be versioned, it was just a 1 time thing really.
Can I delete it for good so GIT doesn't keep track of it going forward or historically?
I backed up my database to GIT just so I could get the db at my home computer.
I don't want this file to be versioned, it was just a 1 time thing really.
Can I delete it for good so GIT doesn't keep track of it going forward or historically?
I always find Guides: Completely remove a file from all revisions feed helpful.
To remove the file called
Rakefile:git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch Rakefile' \ --prune-empty --tag-name-filter cat -- --allThis command will run the entire history of every branch and tag, changing any commit that involved the file
Rakefile, and any commits afterwards. Commits that are empty afterwards (because they only changed the Rakefile) are removed entirely.
I would like to share most simplest and easy to understand solution which worked for me.
First clone a fresh copy of your repo, using the --mirror flag:
git clone --mirror https://github.com/username/youproject.git
Then Download latest version of BFG jar file from https://rtyley.github.io/bfg-repo-cleaner/ rename it as bfg.jar and paste it inside YourRepoName.git folder.
Then run following lines in git bash.
java -jar bfg.jar --delete-files yourfilename (only file name is needed, no need to mention path)
git reflog expire --expire=now --all && git gc --prune=now --aggressive (it will strip out the unwanted dirty data which has been expelled out due to above command)
I faced issue here. My project was having open pull requests. If there are any open pull requests then you need to run this command
git show-ref | cut -d' ' -f2 | grep 'pull-request' | xargs -r -L1 git update-ref -d
After this you can simply push master branch.
git push -u origin master
Its done. But remember to keep a copy in local of old repository before performing above action. All unmerged branches and open pull requests may get deleted.
I reduced my repo size from 40mb to 4mb by removing unwanted apk files which got pushed with my commits.