Automatically show status after git add

后端 未结 4 1345
猫巷女王i
猫巷女王i 2021-01-02 03:03

My usual git workflow is


git add FILES
git status
git commit -m \"some remarks\"

where I need the git status

4条回答
  •  耶瑟儿~
    2021-01-02 03:51

    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.

提交回复
热议问题