Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active December 1, 2021 05:15
Show Gist options
  • Select an option

  • Save keyle/93d1460afdadf758e0bd5a4220f9c9fd to your computer and use it in GitHub Desktop.

Select an option

Save keyle/93d1460afdadf758e0bd5a4220f9c9fd to your computer and use it in GitHub Desktop.
update but automatic stashing if there are local changes first then merge back
update() {
YEL="\033[1;33m"
NOP="\033[0m"
output="$(git status --porcelain)"
if [[ -n $output ]]
then
printf "%s\n" "$output"
echo ""
echo "${YEL}stashing...${NOP}"
echo ""
git stash
echo ""
echo "${YEL}updating...${NOP}"
echo ""
git pull --all
echo ""
echo "${YEL}popping...${NOP}"
echo ""
git stash pop
echo ""
echo "${YEL}done...${NOP}"
echo ""
else
echo ""
echo "${YEL}nothing to stash... updating...${NOP}"
echo ""
git pull --all
echo ""
echo "${YEL}done...${NOP}"
echo ""
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment