我不確定這是怎么發生的(也許我輸入了命令列vi ~ /extra/space.txt?)但是現在有一個名為~staged for commit的檔案。我不想將它添加到 git,并且rm ~在考慮可能的副作用之前我很猶豫要不要嘗試。
$ 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: ~
uj5u.com熱心網友回復:
使用反斜杠將其轉義
rm \~
或者,您可以使用單引號來避免 shell 解釋(而不是逃避 shell 解釋)
rm '~'
由于提交是暫存的,您還需要在合并之前通過add再次 ing 洗掉的檔案(因此它的缺失被合并到暫存的提交中)或reset-ing 洗掉的檔案(這可能發生,因為您使用了git add -a)來清除它
git add \~
雖然您的擔心是實際的,但也不要擔心,rm不會洗掉目錄,只會洗掉檔案,而不提供一些標志 ( -d, -r, -R..)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/317395.html
