Every day I need to sync up branches in git to account for the following:
- Changes made to the remote
- Changes made to the current branch from the origin
In looking for ways to make to some simple shortcuts, I found Nicolas Fränkel's blog post on Creating Git shortcuts and How to get the name of the current git branch into a variable in a shell script? to be particularly helpful.
By using the techniques described in each of these articles in concert, I have defind the following git aliases.
Opens the current folder in Visual Studio Code.
alias open="code ."
$branch as the current branch.
alias get-branch="branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')"
Pulls the branch set to
$branch from the origin.
alias sync-branch="git pull origin $branch"
Pulls the remote
main branch into the current branch.
alias sync-main="git pull upstream main"