Skip to content

Instantly share code, notes, and snippets.

@reschenburgIDBS
Last active January 25, 2022 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reschenburgIDBS/9cbf7e9c81142a0a17869f72aba9c2e8 to your computer and use it in GitHub Desktop.
Save reschenburgIDBS/9cbf7e9c81142a0a17869f72aba9c2e8 to your computer and use it in GitHub Desktop.
git lazy - aliases/functions for simple repeating git tasks
# git lazy - add all files, commit all files and publish all changes
function gl {
echo "${BOLD}${MAGENTA}[ Git Lazy ]${END}"
PRETTYBRANCH=$(script -q /dev/null git status -sb | head -1)
echo "${BLUE}On branch${END} $PRETTYBRANCH"
echo "${YELLOW}+ Pull${END}"
git pull
echo "${YELLOW}+ Adding files${END}"
git status -s
git add --all
local MSG=$@
echo "${YELLOW}+ Commit${LOW} $MSG${END}"
git commit --all -m "$MSG"
echo "${YELLOW}+ Push${END}"
git push
}
# git branch - start a new feature
function gb {
echo "${BOLD}${MAGENTA}[ Git Branch ]${END}"
echo "${YELLOW}+ Pull${END}"
git pull
echo "${YELLOW}+ Creating new branch${END}"
git checkout -b "$1"
echo "${YELLOW}+ Publishing new branch${END}"
git push -u origin "$1"
}
# Git Rebase but pull the remote version of the branch being rebased
# $1 the branch to rebase from
function gr {
CURRENT_BRANCH="$(git status | grep "On branch" | cut -f3 -d" ")"
git fetch && git checkout "$1" && git pull && git checkout "$CURRENT_BRANCH" && git pull && git rebase "$1" -i
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment