Skip to content

Instantly share code, notes, and snippets.

Last active September 14, 2023 19:02
Star You must be signed in to star a gist
What would you like to do?
My current .gitconfig aliases
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
cm = commit -m
aacm = !git add -A . && git commit
aacm = !git add -A . && git commit -m
cp = cherry-pick
amend = commit --amend -m
dev = !git checkout dev && git pull origin dev
staging = !git checkout staging && git pull origin staging
main = !git checkout main && git pull origin
master = !git checkout master && git pull origin
po = push origin
pu = !git push origin `git branch --show-current`
pod = push origin dev
pos = push origin staging
pom = push origin main
poh = push origin HEAD
pogm = !git push origin gh-pages && git checkout master && git pull origin master && git rebase gh-pages && git push origin master && git checkout gh-pages
pomg = !git push origin master && git checkout gh-pages && git pull origin gh-pages && git rebase master && git push origin gh-pages && git checkout master
plo = pull origin
plod = pull origin dev
plos = pull origin staging
plom = pull origin main
ploh = pull origin HEAD
unstage = reset --soft HEAD^
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
f = "!git ls-files | grep -i"
gr = grep -Ii
la = "!git config -l | grep alias | cut -c 7-"
Copy link

fan-tom commented Nov 24, 2020

  update = "!fn() { \
    repo=${2:-origin}; \
    if [[ $(git rev-parse --abbrev-ref HEAD) = \"$1\" ]]; \
    then \
        git pull \"${repo}\"; \
    else \
        git fetch \"${repo}\" \"$1\":\"$1\"; \
    fi; \
    }; fn"

update master without checkout: git update master
update develop from upstream remote: get update develop upstream

Copy link


Any idea how to make those aliases to work with both master and main branch names? So that for example if main branch exists, pom pushes to main, if not, it pushes it to master.

git symbolic-ref refs/heads/master refs/heads/main will alias master to main. Not quite the answer I think you were looking for, but it should work.

Copy link

I have following alias now: main = !git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4

git main returns main or master or any other default branch name for the origin/HEAD.

Then I use it in my aliases like this:

  com = "!f(){ git checkout $(git main) $@;}; f"

Which for example is an alias for checking out the default branch.

Copy link

I have attempted to create a repository using curl and the RESTful Github API, The libcurl command works in the bash shell but not as an alias could somebody help me with this? Sorry in advance for necro'ing an old post but it is the most relevant to the work i am doing :)

create = !curl -H 'Authorization: token <My_Access_Token>' -d '{ "name": "<Repo_Name>", "private": false }'

Before anyone asks, Yes i have interchanged <My_Access_Token> with my actual developer token, same with <Repo_Name>

Look who I've found :O

Copy link

Thank you for share this.

Copy link

o6uoq commented Nov 9, 2022

Use Oh My Zsh

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