How do I print a welcome message containing my git aliases when I open a git bash in Windows?
 
    
    - 2,752
- 2
- 41
- 66
- 
                    which command would you run manually to get the output you want to see? – Thorbjørn Ravn Andersen Oct 29 '12 at 11:47
- 
                    I don't know, I may have to do this manually, like `echo "Available aliases: au : add -u, ct = commit...` – chwi Oct 29 '12 at 12:02
- 
                    which _git_ command would you run manually? – Thorbjørn Ravn Andersen Oct 29 '12 at 12:10
- 
                    Some command that prints a welcome message when I open git bash from Windows – chwi Oct 29 '12 at 12:58
- 
                    You would still need my answer to input an (updated) list of aliases in /etc/motd though ;) – VonC Jul 04 '17 at 09:24
2 Answers
Simply define a HOME environment variable, (not defined in the git-bash.bat script included in msysgit).
In the directory you have chosen (for instance: %USERPROFILE%), define a .bashrc file, with the following content:
git config --get-regexp alias
(from "How to list/show Git aliases?")
That will display all your git aliases each time you open a bash session with msysgit.
alias.st status
alias.lg log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relati    ve
alias.co checkout
alias.ci commit
alias.br branch
alias.lo !sh -c 'git log $1' -
alias.impact !git ls-files -z | xargs -0n1 git blame -w -C | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/' | sed -r 's/ +$//' | sort -f | uniq -c | sort -nr
However, the OP Wilhelmsen asks in the comments:
Do you know how I can omit the word alias on the print?
Sure, this is a basic bash String manipulation operation:
a=$(git config --get-regexp alias)
echo "${a//alias./}"
That will display:
st status
lg log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relative
co checkout
ci commit
br branch
lo !sh -c 'git log $1' -
impact !git ls-files -z | xargs -0n1 git blame -w -C | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/' | sed -r 's/ +$//' | sort -f | uniq -c | sort -nr
Note the ${a//alias./} in order to replace all 'alias.' from the String 'a' by an empty String.
And the double quotes for the echo "$..." are mandatory to keep the newlines in place. (otherwise, all the aliases would be displayed on one line).
- 
                    @Wilhelmsen http://support.microsoft.com/kb/310519 or http://www.itechtalk.com/thread3595.html (ok, I didn't see your last edit to your comment) – VonC Oct 29 '12 at 13:05
- 
                    
- 
                    1@Wilhelmsen I have edited the answer to address your last comment/question, removing the '`alias.`' from the output. – VonC Oct 29 '12 at 13:29
The contents of /etc/motd are displayed on the terminal after an interactive login to the Bash shell (bash --login). If the version of Git for Windows you have omitted the file /etc/motd, create one with cat or your favorite editor.
# == Git Bash on Windows ==
#  - /etc/motd  = Message of the Day 
# - - - - - - - - - - - - -    
cat > /etc/motd
Welcome to the Git Bash Shell
- Try "pwd -W" versus "pwd -L"
- - - - - - - - -
CTRL-D
 
    
    - 156
- 1
- 6
 
    