Skip to content

Instantly share code, notes, and snippets.

@juandspy
Last active October 6, 2023 14:23
Show Gist options
  • Save juandspy/01ecf068f068dacd60802be2ec03e7b8 to your computer and use it in GitHub Desktop.
Save juandspy/01ecf068f068dacd60802be2ec03e7b8 to your computer and use it in GitHub Desktop.
Useful git commands

Useful git commands

I'm using zsh's git plugin for the alias like gp.

  1. Check out the master/main (default) branch for the repo and pull the latest changes.
DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch" | sed 's/.*: //') && \
  git checkout "$DEFAULT_BRANCH" && \
  git pull origin "$DEFAULT_BRANCH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment