Ignoring hidden git files

I have added files ending in ~in my repository on GitHub and now I want to delete them.

For example, I added:

README.md

and file

README.md~ 

.

Any help please?

+5
source share
3 answers

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).

# Ignore all emacs backup files
*~

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
+10
source

gitignore, , .

,

git rm README.md~

.

+2

, git rebase -i:

  • git rm, *~ .gitignore .
  • git rebase -i commit_before_the_file_was_added
  • , , , , "" "fixup"
  • , , .
  • , , git push -f.

... , .

0
source

All Articles