自动添加git后显示状态 [英] Automatically show status after git add

查看:141
本文介绍了自动添加git后显示状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我常用的git工作流程是

 < make changes> 
git add文件
git status
git commit -m一些备注

我需要 git status 来检查我是否添加了正确的文件。



一种告诉 git 自动显示每个 git add

解决方案

您可以使用别名

  [别名] 
gitadd =!sh -c'git add - $ @ && git status' -

进行更改
$ git gitadd文件
$ git commit -m某些注释
git 别名从存储库root工作 1 ,您可以修改别名以使其可以从任何其他目录:

  [别名] 
gitadd =!sh -c'cd$ 1&&移位&& git add - $ @&& git status' -

现在通过说

  git gitadd $ PWD file1 file2 ... 

1 :请注意,shell命令将从存储库的顶级目录,可能不一定是当前目录。


My usual git workflow is

<make changes>
git add FILES
git status
git commit -m "some remarks"

where I need the git status just to check if I added the correct files.

Is there a way to tell git to automatically display the status after each git add?

解决方案

You can use an alias:

[alias]
    gitadd = !sh -c 'git add -- "$@" && git status' --

make changes
$ git gitadd FILES
$ git commit -m "some remarks"


Since git aliases work from the repository root1, you could modify the alias to make it work from any other directory:

[alias]
    gitadd = !sh -c 'cd "$1" && shift && git add -- "$@" && git status' -- 

Now invoke it by saying

git gitadd $PWD file1 file2 ...

1: Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory.

这篇关于自动添加git后显示状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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