Git For Windows: Aliases

I just got a new laptop at work and when setting up Git moved to Git For Windows.  One challenge I ran accross was where to put my aliases.  I have several I used that made my life easier.

Step 1 – Find the location of the git config file

To do this I opened gitbash and executed $ git config --list --show-origin

Which produced the following:

$ git config --list --show-origin
file:"C:\\ProgramData/Git/config"       core.symlinks=false
file:"C:\\ProgramData/Git/config"       core.autocrlf=true
file:"C:\\ProgramData/Git/config"       core.fscache=true
file:"C:\\ProgramData/Git/config"       color.diff=auto
file:"C:\\ProgramData/Git/config"       color.status=auto
file:"C:\\ProgramData/Git/config"       color.branch=auto
file:"C:\\ProgramData/Git/config"       color.interactive=true
file:"C:\\ProgramData/Git/config"       help.format=html
file:"C:\\ProgramData/Git/config"       http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:"C:\\ProgramData/Git/config"       diff.astextplain.textconv=astextplain
file:"C:\\ProgramData/Git/config"       rebase.autosquash=true
file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig"    credential.helper=manager

As you can see my git config file is located in “C:\ProgramData\Git\config”.  I am sure that this is due to some policy that is on the laptop becuase this is not where the documenation says it should be.

Step 2 – Add the aliasas

Now that I know where the config file is I can add the alisases, here are mine.

ci = commit --verbose
cn = commit --verbose --amend
ca = commit --verbose --all
cw = commit -m \"WIP\"
cm = commit -m
cc = commit -c
b = branch
bc = checkout -b
a = add
aa = add --update
ap = add --patch
c = checkout
f = fetch
pr = pull --rebase
pom = push origin master
r = rebase --interactive HEAD~10
rc = rebase --continue
ra = rebase --abort
s = status
sp = -p status # with pagination
ss = -p status -s
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
alias = config --get-regexp 'alias.*'

My updated config file looks like this now.

[core]
    symlinks = false
    autocrlf = true
    fscache = true
[color]
    diff = auto
    status = auto
    branch = auto
    interactive = true
[pack]
[help]
    format = html
[http]
    sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
[diff "astextplain"]
    textconv = astextplain
[rebase]
    autosquash = true
[alias]
    ci = commit --verbose
    cn = commit --verbose --amend
    ca = commit --verbose --all
    cw = commit -m \"WIP\"
    cm = commit -m
    cc = commit -c
    b = branch
    bc = checkout -b
    a = add
    aa = add --update
    ap = add --patch
    c = checkout
    f = fetch
    pr = pull --rebase
    pom = push origin master
    r = rebase --interactive HEAD~10
    rc = rebase --continue
    ra = rebase --abort
    s = status
    sp = -p status # with pagination
    ss = -p status -s
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
    lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
    alias = config --get-regexp 'alias.*'

Step 3 Save and Test

Once I updated my config file, I saved it and then opened a new gitbash windows and BAM! All of may aliases were back.  Happy Day!

Calendar

<<  March 2024  >>
MonTueWedThuFriSatSun
26272829123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Widget Category list not found.

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

Tag cloud

    Widget Month List not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget AuthorList not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X

    Widget TextBox not found.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))X