git commit -m 不工作

git commit -m not working

我今天一直在使用 git commit -a 提交我的本地存储库并输入我的提交消息。一切顺利。

一天结束时,我想通过单行提交来提交一个小的更改,所以我使用了 git commit -m "some message" 并得到了以下内容:

On branch ChartFeature
Your branch is ahead of 'origin/ChartFeature' by 2 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
        modified:   SomeFolder/Scripts/app/SomeScript.js

no changes added to commit

我做错了什么?

如何让 git 再次允许 commit -m

脚注:在使用 -m 失败了几次并且发现 git log origin/ChartFeature..HEAD 没有任何问题后,我像以前一样尝试了 git commit -a 并且它工作了(如预期的那样)虽然 git commit -m仍然没有。

首先你需要添加修改后的文件: 使用:

git add SomeFolder/Scripts/app/SomeScript.js

然后使用:

git commit -m"Some message"

然后

git push origin <the branch>
git commit -m 

仅当您之前执行过 git add something 时才有效!

仅此而已!换句话说:你没有添加(暂存)任何东西;因此你不能提交!

git -a

自动添加(某些)类型的更改; -m 没有!

您的状态消息告诉您:

更改未暂存 提交: 修改:SomeFolder/Scripts/app/SomeScript.js

首先使用以下任一方法将修改后的文件添加到 git:-

git 添加 -A 阶段全部

git 添加 .阶段新的和修改的,没有删除

git add -u stages modified and delete, without new

我更喜欢git 添加-A。

然后尝试提交,它会起作用

Changes not staged for commit:

您需要先 Add 然后 Commit

$ git commit -am 'Message'   # changes are staged & commit 

在推送任何更改之前,您可能需要合并 'origin/ChartFeature'。

按照以下步骤操作

首先,使用

添加所有更改

git add -A

然后提交您的更改

git commit -m "message"

在对分支进行推送之前,只需拉一次,这会将您的代码与远程分支合并。如果您想在合并之前查看此代码,则可以使用 git fetch

git pull origin the branch

然后将更改推送到相应的分支

git push origin the branch