fo_x86
fo_x86

Reputation: 2613

Cygwin git not picking up aliases

I'm using Cygwin and the git (v1.7.9) that came with it by default (/usr/bin/git). I also have msysgit (v1.7.11.msysgit.0) installed. In my .bashrc, I do

export GIT_CONFIG=path_to_.gitconfig

and when I run git config --list, I get the contents of my .gitconfig (relevant excerpt below):

 ...
 alias.co=checkout
 alias.br=branch
 alias.ci=commit
 alias.st=status
 alias.logp=log --pretty=format:"%h - %an, %ar : %s"
 alias.logl=log --pretty=oneline
 alias.graph=log --pretty=format:"%h - %an : %s" --graph
 ...

however, if I run git ci -m "this is a test" I get

 git: 'ci' is not a git command. See 'git --help'.

 Did you mean one of these?
    am
    citool
    commit
    config
    diff
    fsck
    gc
    init
    mv
    rm

Does the git that comes with cygwin have to be set up differently?

Upvotes: 2

Views: 984

Answers (2)

T. Junghans
T. Junghans

Reputation: 11683

I solved this by including the git aliases with the alias command in the .bash_profile:

alias gch='git checkout'
alias br='git branch'
alias ci='git commit'
alias gs='git status'
alias gcd='git checkout develop'
alias gcm='git checkout master'
alias gph='git push'
alias gpl='git pull'
alias unstage='git reset HEAD --'
alias ga='git add -u .'

Upvotes: 0

fo_x86
fo_x86

Reputation: 2613

Figured, that git will try writing to the .gitconfig file it was loading when aliasing a new command so I ran git config --global alias.testalias random_git_command. Then from my home directory

 grepc -R testalias ./

I was able to determine that it was using ~/.gitconfig. So the solution was to make a symlink ln -s [path_to_desired_.gitconfig] .gitconfig in my home directory.

Still finding weird that when I ran git config --list I could see the list of aliases, but when I tried running them, git would not recognize them as a valid alias...

Upvotes: 1

Related Questions