To ignore the entire file ending in ~, you must add it to the file .gitignoreat the top level in your repository (next to the directory .git).
*~
Then, to change the history and delete the file, README.md~you can do it manually with git rebase --interactiveor try to use git filter-branch:
$ git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch README.md~' HEAD
source
share