【问题标题】:Commiting all files ignores the ones in .gitignore?提交所有文件会忽略 .gitignore 中的文件吗?
【发布时间】:2015-01-16 16:27:04
【问题描述】:

我是 Git 新手,所以我的问题是:

使用

git commit -a -m "Message"

会尊重 .gitignore 文件吗?如果我跑

git add *

它说不能这样做,因为有文件被更改并标记为被忽略。

【问题讨论】:

  • 谢谢@GoBusto,但不一样...我的问题是关于git commit -a 而不是git add *

标签: git


【解决方案1】:

git-commit 中的-a 标志不会提交工作目录中的所有文件,只是提交已更改的存储库中已经存在的文件。这与git add * 不同,后者使用* 的shell 扩展将所有文件添加到staging,即使是git 以前没有管理过的文件。

(From git-commit man page)

-a --全部

告诉命令自动暂存已经修改和删除的文件,但是你没有告诉git的新文件是 不受影响。

【讨论】:

  • 感谢您的回复。所以,我想这样做:git add specific/file.js 将添加文件,git commit -a 也会添加该文件,对吧?
猜你喜欢
  • 2018-05-02
  • 1970-01-01
  • 2014-09-16
  • 2013-03-16
  • 1970-01-01
  • 2021-09-29
  • 2022-11-16
  • 2021-09-24
  • 1970-01-01
相关资源
最近更新 更多