Reputation: 13514
I had my git setup and working and i have specified .a libs in .gitignore
so large files don't get uploaded. But in one particular commit I removed it from .gitignore
and then committed it. After pushing it gave me error that I cant push large files and for that I require Git LFS. I don't want to use Git LFS. I made some changes in code and updated those big files to .gitignore
but still those files are getting pushed. Any solution how to overcome the above scenario.
I tried to create a new branch from the above branch and tried to push the commit but in the new branch but its all the same.
Upvotes: 1
Views: 978
Reputation: 6318
You can always rewrite your commit history in-place by using git rebase
. Be aware that already pushed commits should not be modified by this method.
For example: Use git rebase -i <BASE_COMMIT>
to rewrite the history up to BASE_COMMIT
(insert a commit hash prior to your commit to delete here). Then, git presents you with a list of all commits up to HEAD. Here, you can simply modify those commits by changing the keywords in front.
In your case, it should be enough to simply change 'pick' to 'drop' in front of your bad commit to remove this single commit from your commit history.
If this bad commit contained other useful information you could also combine ('squash') it with a commit which deletes only the large files. This way, the other parts of your commit remain functional.
Be sure to backup your large files before removing this commit to ensure that they won't get lost.
Upvotes: 4
Reputation: 4061
The files you committed once are not ignored even if you add them to gitignore later. The best solution for this is to use interactive rebase and delete that commit and keep those large files in .gitignore
. It will be as if those files were never committed.
Upvotes: 2