Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用git删除本地分支上的文件_Git_Branch - Fatal编程技术网

使用git删除本地分支上的文件

使用git删除本地分支上的文件,git,branch,Git,Branch,我已经在那里的一些文件中做了一些更改。然后,我在其中添加了一个新文件,使用 git add newfilename 我还没有提交,现在我想删除这个新文件。我不能做重置,因为它将重置所有其他文件更改,我也不;我不想要 我尝试了git checkout newfilename和通常的猜测delete和rm,但没有帮助 试试看 git rm --cached newfilename 至少要将其从索引中删除。git reset newfilename会将其从索引中删除,然后您可以像往常一样将其删除。

我已经在那里的一些文件中做了一些更改。然后,我在其中添加了一个新文件,使用

git add newfilename
我还没有提交,现在我想删除这个新文件。我不能做重置,因为它将重置所有其他文件更改,我也不;我不想要

我尝试了
git checkout newfilename
和通常的猜测
delete
rm
,但没有帮助

试试看

git rm --cached newfilename

至少要将其从索引中删除。

git reset newfilename
会将其从索引中删除,然后您可以像往常一样将其删除。

只需使用以下命令从分支中删除文件:

$git rm文件名