I have a Git repository where I have added, committed and pushed some files a month ago, which, I was now informed, should not have been on the root level and not in the repository at all.
Note that the questions that pop-up as similar here are about undoing "most recent local commits" and unfortunately do not help me as eversince last month, when I committed them, there have been many commits to that branch named 32-nd-branch
. The instruction which I received is
"Please drop them by reverting the commits."
My first thought when reading this was that reverting to the < commit id >, which I found by git log --diff-filter=A -- <file name>
in order to delete (not sure if that is meant by "drop") the files will leave a month of progress burried somewhere deep in the git repo history, and will set the current state of the repository to the one back then.
I want instead, to just go back to that commit which I added that particular file, delete the file and then, most importantly, push this change to that commit without affecting any other files, if possible, without changing the hash of the commit. But then this file I delete in this old commit would be there in all subsequent ones, right? So how do I delete this unwanted file from all of the commits following it's creation in the repository?