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!

mysysGit 1.7.4 Running Slow on Windows 7

CropperCapture[8]

The other day I was finally feed up.  Every day when I open my Git Bash window to pull in some new changes or push an update to GitHub the commands just seem to take forever to run.  Even just  a simple ls outputs the directory information to the screen but takes about 8+ seconds before the prompt returns.

I finally resolved myself to figuring out how to speed things up.  As usual Stack Overflow (http://stackoverflow) to the rescue.  Someone else was also experiencing the same issue, Git/Bash is extremely slow in Windows 7 x64.

The solution for me was to uninstall mysysGit 1.7.4, re-install, and then reboot.  Now the Git Bash command return almost instantly.

Oh, don’t forget to backup any files you may have had in the git home directory, like .gitignore, etc.

***UPDATE - 6/28/2011***

This turned out to be only part of my problem, the next day the slowness returned.  After doing a little more investigation I determined that my $HOME was being set to %HOMEDRIVE$%HOMEPATH%.  Which for me turned out to be a network mapped drive, my company has a logon script that maps me to a networked home drive.  This also explains some issues I had with configs when not on the work network since it was looking in two places.

The next solution was to create an environment variable HOME and point to to where I wanted all of my config files to reside, not on the network of course Winking smile.  To keep it simple and to make it work for all users I pointed HOME to %USERPROFILE%.

Now, the Git Bash commands are running a lot faster.

Set Home Directory for msysGit

I have been using git (msysgit on windows) a lot lately.  One thing that really bothered me was that I couldn’t find a way to set the home directory.   I wanted the Git Bash to open pointed to the directory C:\Solutions, this is where all of my source code resides.  I am not sure if there isn’t a way to specify it or I just didn’t find it.  I did however come up with a way that I can get it to open to the directory of my choice. 

image

In Windows 7 do a search for git, right click and select properties.

image

Change the value of Start in to point to the directory you want Git Bash to start in.  Click OK to close and save the information.

image

Launch Git Bash, here I am using Executor (http://executor.dk).

image

Git Bash will open at the path you specified in the Start in. 

This did not change the home path, all .gitconfig, .bashrc, etc files are still located at ~.  This just caused Git Bash to open pointed to the directory of your choice.

Oh, and another thing, if you re-install or upgrade msysgit you will have to reset the value to point to your directory.  The installer overwrites the shortcut.

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