Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.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 - Fatal编程技术网

git忽略修改过的文件,以便我可以更改分支

git忽略修改过的文件,以便我可以更改分支,git,Git,我创建了一个“用户”分支,在其中我做了大量更改,包括一个.less文件。我打开了一个更少的编译器,它会在保存时自动编译。当我改为master分支时,编译了.less文件,因此我的.css文件现在在master上有所不同。所以现在我不能合并用户(包括提交)或切换回用户分支 我得到以下错误: 我是否可以撤销该文件或忽略该文件,以便合并到“用户”中 我试图签出该文件,但没有成功: git checkout media/less/content/public/template.css 导致 paths

我创建了一个“用户”分支,在其中我做了大量更改,包括一个.less文件。我打开了一个更少的编译器,它会在保存时自动编译。当我改为master分支时,编译了.less文件,因此我的.css文件现在在master上有所不同。所以现在我不能合并用户(包括提交)或切换回用户分支

我得到以下错误:

我是否可以撤销该文件或忽略该文件,以便合并到“用户”中

我试图签出该文件,但没有成功:

git checkout media/less/content/public/template.css
导致

pathspec“media/less/content/public/template.css”与任何 git已知的文件


您可以重置一次提交,然后查看更改的文件,清理并再次提交

git reset HEAD~1
git status # you'll see the files that changed

# probably you need to do this
git checkout media/less/content/public/template.css 
git commit -m "..."
git push -f # to update the last commit

这不会直接解决您的问题,但这正是派生文件不属于源代码管理的原因。css文件一开始就不应该签入。
git reset HEAD~1
git status # you'll see the files that changed

# probably you need to do this
git checkout media/less/content/public/template.css 
git commit -m "..."
git push -f # to update the last commit