An alias that will generate a git commit message staged changes as shown in git-status. Put this alias (section below) in your .gitconfig
.
The message generated will be in the format of:
$ git status --porcelain
A file1.py
A file2.py
A file3.py
M file4.py
M file5.py
D README.md
R test.txt-> test2.txt
$ git commit-status
$ git log --no-decorate -n 1
bee4f8e Added: file1.py file2.py file3.py Modified: file4.py file5.py Deleted: README.md Renamed: test.txt-> test2.txt
Shared on Stack Overflow.
@isayakmondal Cool, go for it! You can use any language to execute the commands needed to get the input for the program, meaning that a Python/C/whatever can execute
$ git status --porcelain
, get the output of this command, then do the logic of formatting the message, and executegit commit
with this message.I would recommend looking in to Python; it's easiest to pick up and yet powerful :)
This solution was made in bash to not require dependencie e.g. Python, so that it can be used directly by anyone. But if you want to make something proper, bash is likely not the right answer for many cases.