I know this question has already been asked, but in every answer, I found the situation is slightly different from mine and I don't see how to adapt it.
So here is the problem:
I cloned a repository and added a folder to work in it. In this folder, I added .csv files and .py files that use the csv ones. I tried to push this but realised it was taking to long as 2 csv files are very big. So i
git rm files
and then commit. I tried to push again and only then realised that removing a file doesn't remove it from the git history .// So now, from the last completed push, I have 2 commits: 1 where I added the files, 1 where I deleted some .csv.
I would like your help to delete the last 2 commits. Is that feasible? Thanks
filter-branch, as has been advised is fine if we are talking about biiiig histories. If we are talking of only a handful of revisions, you can do it (remove the files) by just amend the revision where you added the file and cherry-pick, or rebase interactive.
One example..... say I added file a.txt on master~2. I don't want it on the history anymore.
git checkout master~2 git rm --cached a.txt git commit --amend --no-edit git cherry-pick master~2..master git branch -f master # point master in this revision git checkout master
That should be enough.