Skip to content

Instantly share code, notes, and snippets.

@smw7156
Last active January 20, 2025 06:35
Show Gist options
  • Save smw7156/1d3581a1798990e05762944d5e680ddc to your computer and use it in GitHub Desktop.
Save smw7156/1d3581a1798990e05762944d5e680ddc to your computer and use it in GitHub Desktop.
Aliases for git command in windows

I am using powershell in windows 11 (I don't like windows, but my company uses only windows machine) so, there is a file that is loaded whenever you start your powershell program in windows. that is $PROFILE

This file might not be present if you have newly installed windows in your machine, but the path is already defined.

Type echo $PROFILE and it will print the path.

You can open the path in any editor of your choice, and add these lines in that file for creating the alias

Note: these are general alias that can be run from any path in powershell. you can obviously create aliases other than git as per your use case

For git

function gbr { git branch --show-current }
function gbrl { git branch --list $args }
function gsts { git stash save $args }
function gst { git status }
function gbl { git branch $args }
function glogs { git log --pretty=oneline $args }
function glogm { git log --pretty=medium $args }
function glog {
    git log --pretty=format:"%C(yellow)%h%x09%C(green)%ad%x09%C(blue)%an%x09%C(auto)%d%s" $args
}
function gloga {
    glog --all --graph $args
}
function gcma {
        git commit -a
}
function gcm { git commit }
function gpo {
    $brName = gbr
    git push origin $brName
}
function gcmap {
    gcma
    gpo
}
function gcmp {
    gcm
    gpo
}
function gfo {
    git fetch origin
}
function gch {
    git checkout $args
}
function gchb {
    git checkout -b $args
}
@smw7156
Copy link
Author

smw7156 commented Jan 20, 2025

updated Commit process. -> now you have to explicitly add untracked file
added checkout command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment