I've managed to commit some files incidentally in commit A001. Those files are quite big (around 100MB each). After noticing my mistake, In next commit, I've deleted those files with rm command, and commited those changes to commit A002. I've thought that this solved my problem and continued developing. After few commits, let's say commit A005 I've tried to push everything on remote (Large files have been deleted, but they're still commited in commit A001), push fails with following message:
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
...
...
! [remote rejected] melodic-dev -> melodic-dev (pre-receive hook declined)
Which is okay, because large files still exist in commit A001.
How can I do following:
- Go back to commit
A001, unstage those large files and recreate commitA001without those large files that have been removed, do same to commitA002 - Recreate all following commits
A003-A005as they were on tip of the recreatedA001_edited-A002_editedcommits without those large files - Push corrected
A001-A005commits to remote branch
I would need something like: Create new branch that has all commits NEW_BRANCH:A001-A005. In that branch, I would like to remove some files from commit A001, therefore i would have NEW_BRANCH: A001_edited commit, and I would like to merge OLD_BRANCH:A001-A002-A003-A004-A005 with NEW_BRANCH: A001_edited-A002_edited so that I have following: OLD_BRANCH: A001_edited-A002_edited-A003-A004-A005
A001_edited = A001 without commiting (revert git add Large files) those large files
A002_edited = A002 without removing (revert git rm Large files) those large files
In two successive commits somewhere in history, I want to remove some staged/unstaged files and keep everything else the same.
I've tried some stuff, but without success. I hope I've clarified my problem enough, if not let me know :)
Thank you for your time and help.