Last active
January 25, 2022 14:58
-
-
Save reschenburgIDBS/9cbf7e9c81142a0a17869f72aba9c2e8 to your computer and use it in GitHub Desktop.
git lazy - aliases/functions for simple repeating git tasks
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
# 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