Sourced git alias fails

I have setup a custom git alias to make a pretty git log like this in my ~/.gitconfig

[alias]
   l = "!source ~/.githelpers && git_pretty_log"

My ~/.githelpers file contains the following:

  • Bash: How to compose functions where the inner function will return an argument
  • Use of apostrophe (single-quote) in a git commit message via command line?
  • why is there a delay when trying to update remote master on github?
  • Any command to store Git username password without inital prompt
  • How can i add an administrative build in jenkins?
  • git edit authors name in commit range, script
  • #!/bin/bash
    
    HASH="%C(yellow)%h%C(reset)"
    RELATIVE_TIME="%C(green)%ar%C(reset)"
    AUTHOR="%C(bold blue)%an%C(reset)"
    REFS="%C(red)%d%C(reset)"
    SUBJECT="%s"
    
    FORMAT="$HASH{$RELATIVE_TIME{$AUTHOR{$REFS $SUBJECT"
    
    function git_pretty_log() {
        git log --graph --pretty="tformat:$FORMAT" $* |
        column -t -s '{' |
        less -FXRS
    }
    

    But when I do git l in any repo I have I get:

    $ git l
    source ~/.githelpers && git_pretty_log: 1: source ~/.githelpers && git_pretty_log: source: not found
    fatal: While expanding alias 'l': 'source ~/.githelpers && git_pretty_log': Aucun fichier ou dossier de ce type
    

    Any ideas?

  • Making a Git project open source when you have secret keys
  • Is there a “git touch” so I can push the same file with a new timestamp?
  • Error when trying to set build status
  • why not deploy code directly from git or bzr repository?
  • Possible to have multiple git users logged in as root?
  • Git-SVN clear auth-cache
  • 2 Solutions collect form web for “Sourced git alias fails”

    The error seems to be that source is not an external binary, but instead a bash builtin.

    $ git config alias.foo '!source .gitfoo'
    $ git foo
    source .gitfoo: 1: source .gitfoo: source: not found
    

    Wrapping all this with a bash -c solves the problem.

    $ git config alias.foo '!'"bash -c 'source .gitfoo && gitfoobar'"
    $ echo 'function gitfoobar() { echo foo bar; }' >.gitfoo
    $ git foo
    foo bar
    

    For your case:

    git config --global alias.l '!'"bash -c 'source ~/.githelpers && git_pretty_log'"
    

    Remove the quotation marks; it should just be:

    [alias]
        l = !source ~/.githelpers && git_pretty_log
    

    Otherwise, you’re trying to run one long command that doesn’t exist, just as the error message told you.

    Git Baby is a git and github fan, let's start git clone.