git branch commit如何忽略修改后的文件

时间:2014-08-06 17:06:09

标签: git git-branch

您好我正在研究symfony项目的一个分支(私人目录)

我确实修改了config.yml以检查翻译..

在提交时,它显示了我(来自主人的跟踪文件)

modified : app/config/config.yml , .gitignore

我做了

git rm --cached app/config/config.yml , .gitignore

然后

git commit and git push

现在这些文件在github分支中显示为“已删除”..

有没有办法放弃这个删除,只是忽略对这些文件的本地更改?

我曾尝试过:

git update-index --assume-unchanged  app/config/config.yml

但返回:无法标记文件

我的.gitignore allready列出了两个文件,但似乎没有效果..

提前感谢您对我的问题的启发,因为我现在真的被困了

1 个答案:

答案 0 :(得分:0)

你还没有提交,对吧?

尝试:

git reset HEAD app/config/config.yml

编辑:刚刚阅读:您已经git commitgit push了。你几乎搞砸了。你不应该修改推送的提交,但你可以像这样做一个恢复提交:

git stash
git checkout HEAD^ app/config/config.yml
git add app/config/config.yml
git commit -m "reverting removal of config.yml" #(or whatever commit message you want)
git stash pop