提交并自动添加所有未跟踪的文件 [英] Commit and automatically add all untracked files

查看:83
本文介绍了提交并自动添加所有未跟踪的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常忘记拥有一些新文件而直接这样做,

I often forgot that I have some new files and directly do,

git commit -a -m "My commit message"

这仅提交更改的文件,我必须将其余文件添加到新的提交中.这意味着尽管逻辑上它们是同一任务的一部分,但是有两个单独的提交.

This only commits changed files, and I have to do add the remaining files in a new commit. This means that there are two separate commits although logically they are part of the same task.

我知道通过两个连续的命令在提交中包括未跟踪文件的最简单方法:

The easiest way I know to include untracked files in the commit via two consecutive commands:

git add -A
git commit -a -m "My commit message"

在一个命令中是否可能具有与上述相同的效果?

Is it possible to have the same effect like the above in one command?

推荐答案

在执行路径中创建一个名为(无扩展名)的文件:git-add-commit-untracked

Create a file in your execution path called (no extension): git-add-commit-untracked

将其放入其中:

#!/bin/bash
message=${0}
git add -A
git commit -am "$message"

然后: git-add-commit-untracked "Commit message"

不过,您可以为文件使用更短的名称.我把它留得很长,以作说明.

You can use a shorter name for the file though. I left it lengthy for illustrative purposes.

这篇关于提交并自动添加所有未跟踪的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆