【问题标题】:git commit auto add new folders or files?git commit 自动添加新文件夹或文件?
【发布时间】:2012-02-15 21:51:10
【问题描述】:

是否可以让git commit 也添加新文件和目录?

从长远来看,似乎有很多不必要的输入,必须先输入git add .,然后输入git commit

(那个,而且我经常忘记调用git add . 导致版本缺少目录等)

【问题讨论】:

  • 如果您使用 Jetbrais 的 IDE,您将获得一个未版本化文件的列表。你仍然需要添加和提交,但至少你有一个可视化列表。
  • git commit -a 会满足你的需要吗?
  • git commit -a 似乎没有暂存新文件.. 我一直在使用它,但新目录和文件没有自动添加
  • @BenjaminUdinktenCate - 但是 Jetbrains 不支持很多语言,所以如果有一些单行终端命令会很好

标签: git


【解决方案1】:

只要我被告知没有这样的命令(当您有包含密码的调试文件时可能会很危险),但是如果您想模拟您可以将此别名添加到您的 git 配置中:

git config --global alias.commitx "!git add . && git commit"

使用git commitx 现在将运行git add .,然后是git commit,所以你可以这样做

git commitx -m "testing commitx on new unstaged files"

【讨论】:

  • 这似乎是诀窍......我是否只需在终端中输入它进行设置:git config alias.commitx=!git add . && git commit -a -m
  • @ina: 命令是 git config --global alias.commitx '!git add . && git commit -a -m' - 你必须引用命令以防止 bash 解释它,并且 git config(命令)在其语法中不使用 = , 只是 <config-parameter> <value> 作为单独的参数。
  • 谢谢大家 - 这非常有帮助......总的来说,在我和谷歌搜索的用户中,你可能已经节省了数以百万计的微秒! :-)
猜你喜欢
  • 2012-02-15
  • 2020-10-30
  • 2011-02-15
  • 1970-01-01
  • 2018-08-15
  • 2010-12-24
  • 2023-04-11
  • 2015-09-12
  • 2018-08-10
相关资源
最近更新 更多