Adapt-Mobile
2/28/2018 - 8:57 AM

Git aliases

Git aliases to make your life easier!

Git aliases

Add these under the [alias] tag in your .gitconfig file.

Shortcut for resetting

undo = reset --hard 

A nice way to see the log

pl = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

See what commits you made yesterday

standup = log --all --author='Your git name' --since='yesterday' --format=%s

Git flow aliases, creates and pushes branches for you. The branches are named as variant/your-name.

Example: git flow-feature my-feature would become feature/my-feature. Note that the flow-do-release won't work if the master and/or develop branch is locked.

# Custom Flow aliases
flow-init = !sh -c 'git checkout -b develop && git push -u origin develop' -
flow-bug = !sh -c 'git checkout -b bug/$1 && git push -u origin bug/$1' -
flow-feature = !sh -c 'git checkout -b feature/$1 && git push -u origin feature/$1' -
flow-release = !sh -c 'git checkout -b release/$1 && git push -u origin release/$1' -
flow-do-release = !sh -c 'CURRENT=$(git rev-parse --abbrev-ref HEAD) && \
            git checkout master && \
            git pull && \
            git merge $CURRENT && \
            TAG=$(echo $CURRENT| cut -d'/' -f 2) && \
            echo "Tagging version: ${TAG}"  && \
            git tag -a $TAG -m "$(echo "Release:"$TAG)" $(git rev-parse HEAD) && \
            git push --follow-tags && \
            git checkout develop && \
            git pull && \
            git merge $CURRENT && \
            git push' -
flow-clean = !sh -c 'git branch | grep "feature/" | xargs git branch -D && \
      git branch | grep "bug/" | xargs git branch -D && \
            git branch | grep "release/" | xargs git branch -D' -