Last active
April 19, 2018 18:14
-
-
Save deeshank/7ae2494083425ac8afed22902ba4d803 to your computer and use it in GitHub Desktop.
Git Bash one liners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming we have .gitconfig setup | |
# Refer here - https://gist.github.com/deeshank/279d1a77678282b2be18fd3bc4bd1bc7 | |
# git aliases | |
alias g='git' | |
alias gb='git gh' | |
alias pr='git pr' | |
alias gpush='git pb' | |
alias co='git co' | |
alias st='git st' | |
alias lg='git log -5' | |
alias grup='git remote-up' | |
alias gup='git origin-up' | |
hd() { | |
# checkout all the modified files to the head | |
git status | grep modified | cut -d':' -f2 | xargs git co -- | |
} | |
################################################################################ | |
?() { | |
branch=$(git branch | grep -e "^*" | cut -d' ' -f 2) | |
echo $branch | |
echo | |
} | |
################################################################################ | |
??() { | |
br=$(git branch | grep -e "^*" | cut -d' ' -f 2) | |
echo '' | |
echo 'On Branch : '$br | |
branch=$(git branch | grep -e "^*" | cut -d' ' -f 2) | |
remote_origin=$(git ls-remote -h origin $branch | awk '{print $1}') | |
remote_upstream=$(git ls-remote -h upstream $branch | awk '{print $1}') | |
local=$(git rev-parse HEAD) | |
printf "Local : %s\n" $local | |
printf "Remote(Origin) : %s\n" $remote_origin | |
printf "Remote(Upstream) : %s\n" $remote_upstream | |
echo '' | |
if [[ $local == $remote_origin ]]; then | |
echo "Origin - Commits match." | |
else | |
echo "Origin - Commits don't match." | |
fi | |
if [[ $local == $remote_upstream ]]; then | |
echo "Upstream - Commits match." | |
else | |
echo "Upstream - Commits don't match." | |
fi | |
} | |
################################################################################ | |
whichbr() { | |
git branch -r --contains $1 | |
} | |
################################################################################ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment