This script should remove from existence file you don't want in your repo, as you never commited it, nothing more nothing less.
Tested on arch, might not work on other distributions, if not look at condition.
- Download script:
curl -Os https://gist.githubusercontent.com/ultrox/2c3203bcbda3077ee467d9edb1d0ab5e/raw/e477fbeaf8556ac02748809154c95e3e5b6cd04c/git-rmf && chmod u+x git-rmf
- move to $PATH
- Run it like this
git-rmf OFFENDING-FILE
- If you pushed, you need to force it git push --force. If you work with a team, notify them or you'll be new next hated guy.
- Pat yourself on the back, good job!
NOTE: if you removing sensitive file you should run garbage collection to prune dangaling commits and expire reflog, after that there is no undo.
git reflog expire --expire=now --all && git gc --prune=now --aggressive