git - 即使在提交/推送之后也无法摆脱“要提交的更改”消息
问题描述
即使在提交并推送到原点后,我也会不断收到Changes to be committed
来自命令的消息。git status
我可以看到 origin/master 的变化。我怎样才能摆脱这个消息?
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: foo.php
$ git commit -m 'message' foo.php
On branch master
Your branch is up to date with 'origin/master'.
nothing added to commit
编辑
实际上,foo.php 之前是一个不同的名称,比如 foo-org.php,我将其重命名为:
git mv foo-org.php foo.php
我运行 git add foo.php 然后 git commit -m 'renamed' foo.php 然后 git push orign master。我可以看到在线 repo (origin/master) 上的文件是最新的,所以我不知道为什么它仍然说“要提交的更改”。
解决方案
由于远程主分支是最新的,请尝试将本地分支重置为它:
git fetch
git switch -C master origin/master
或者,如果您已经在本地master
:
git reset --hard origin/master
然后检查是否git status
仍然报告非空索引。
推荐阅读
- python - Python DBSCAN - 如何根据向量的平均值绘制集群?
- react-native - 在 React Native 中重新渲染 FlatList 时,未调用 Flatlist onVIewableItemsChanged 属性
- html - 动画 div 不能转换 CSS
- json - SQL Server 2012 的 JSON_VALUE?
- load-balancing - HaProxy:如何记录响应正文
- mongodb - 使用可搜索的嵌套数组设计 mongodb 模式。
- portal - 不要自动刷新嵌入式小部件
- ios - 在缩小期间迅速将 UIScrollView 中的 ImageView 居中
- java - Java:如何使用 spring 注释将 .properties 文件的内容加载到 Properties 中?
- javafx - 选择未更改时,JavaFX ComboBox 可以触发事件吗?