Here are some aliases that I use pretty much everyday. Here, I explain in detailed my aliases use at work. You can find all the code here and here
First off, aliasing g as git. This is default on linux machine.
I use this a lot in the other aliases
g at means git rev-parse --abbrev-ref HEAD
g pr means git pull --autostash --rebase
g reb 3 means git rebase --interative 3
g p means git push
g pf means git push --force-with-lease
Once you checkout a new branch, you have to type that long setting upstream thing. Automate that!
function set_upstream {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
echo "setting up stream branch $CURRENT_BRANCH"
git push --set-upstream origin $CURRENT_BRANCH
}
alias up=set_upstream
You are lazy and don’t want to invent a commit message(because you will rebase it anyway(you are commiting on your own branch, of course!))
function commit_misc {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD);
myArray=("a funny" "a lovely" "a cute" "an adorable" "a pretty" "an elegant" "a charming" "a gorgeous" "a stunning")
num=${#myArray[@]}
index=$((1 + $RANDOM % $num))
adj=${myArray[$index]}
echo "writing $adj commit and push to branch: $CURRENT_BRANCH"
git add .
git commit -m "$adj commit at $(date +%F_%H-%M-%S)"
}
alias misc=commit_misc
You might be lazy typing g p and want to commit and push in one enter!
function commit_misc_then_push {
commit_misc
git push
}
alias miscp=commit_misc_then_push