I'm not sure how this happened (maybe I typed a command line vi ~ /extra/space.txt
?) but there is now a file named ~
staged for commit. I do not want to add it to git, and I'm hesitant to try rm ~
before thinking through possible side effects.
$ git status
On branch master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: apples.js
modified: app/berries.js
modified: app/views/pears.js
new file: app/views/lemons.js
modified: public/stylesheets/oranges.css
new file: ~
CodePudding user response:
Use the backslash to escape it
rm \~
Alternatively, you can use single-quotes to avoid shell interpretation (rather than escaping the shell interpretation)
rm '~'
As the commit is staged, you'll also need to clear it before merging by add
ing the removed file again (so its absence is incorporated into the staged commit) or reset
-ing the removed file (this probably happened because you used git add -a
)
git add \~
While your fears are practical, also don't worry, rm
won't remove directories, only files, without providing some flag (-d
, -r
, -R
..)