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.
add
first, and thenstatus
. E.g.git config --global alias.ad "!git add $1; git status"
, but I’m not sure if you can keep supporting all theadd
parameters that way. – Raeraeann