Automatically show status after git add

后端 未结 4 1282
猫巷女王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:43

    Here's what I have using the answer at https://stackoverflow.com/a/26243454 and combining it with devnull's answer:

    [alias]
        sadd = !sh -c 'cd -- ${GIT_PREFIX:-.} && git add -- "$@" && git status' --
    

    This way you don't need to pass in the working directory manually.

    0 讨论(0)
  • 2021-01-02 03:47

    When run with -v (verbose) option, git add outputs the name of files that were added:

    » git add -v hello?
    add 'hello1'
    add 'hello2'
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-02 04:00

    You can do it via creating an alias that executes add first and then status using git config commnad ..

    0 讨论(0)
提交回复
热议问题