DEV Community

Craig Shoemaker
Craig Shoemaker

Posted on

1 1

My git aliases

I'm lazy.

Every day I need to sync up branches in git to account for the following:

  • Changes made to the remote main branch
  • 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.

open

Opens the current folder in Visual Studio Code.

alias open="code ."
Enter fullscreen mode Exit fullscreen mode

get-branch

Sets $branch as the current branch.

alias get-branch="branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')"
Enter fullscreen mode Exit fullscreen mode

sync-branch

Pulls the branch set to $branch from the origin.

alias sync-branch="git pull origin $branch"
Enter fullscreen mode Exit fullscreen mode

sync-main

Pulls the remote main branch into the current branch.

alias sync-main="git pull upstream main"
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up