微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

git commit -a -m 给出未跟踪文件的错误

如何解决git commit -a -m 给出未跟踪文件的错误

我正在学习使用 git 并且我正在尝试分支。 我创建了一个文件“test.rb”并在“testing”分支上提交了一个版本。

在“master”上我使用 git commit -a -m 'msg' 并收到此消息:

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.rb

nothing added to commit but untracked files present (use "git add" to track)

我不明白为什么,因为“-a”标志应该将所有内容添加到暂存并提交。

我错过了什么? 谢谢!

解决方法

由于test.rb文件还没有被git跟踪,需要添加 首先使用 git add

git add test.rb
git commit -m "msg"

之后,如果您对此文件添加更改,则可以使用 -a 选项提交更改

git commit -am "msg"

git 帮助中 -a 标志的描述也突出显示了这一点:

$ git commit --help
-a,--all
           Tell the command to automatically stage files that have been
           modified and deleted,but new files you have not told Git about
           are not affected.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。