GitHub Cheat Sheet

Published on Author craigzearfossLeave a comment

Checkout a remote branch

  • Before you can start working locally on a remote branch, you need to fetch it as called out in answers below.
  • To fetch a branch, you simply need to:
    git fetch origin
  • This will fetch all of the remote branches for you. You can see the branches available for checkout with:
    git branch -v -a
  • With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy:
    git checkout -b test origin/test
  • EDIT – The answer below actually improves on this. On Git>=1.6.6 you can just do:
    git fetch
    git checkout test

Deleting Branches

  • To remove a local branch from your machine:
    git branch -d the_local_branch
  • To remove a remote branch:
    git push origin :the_remote_branch

Tags

  • Push all tags to remote repository:
    git push --tags
  • Push specific tag to remote repository:
    git push origin
  • Get all tags
    git fetch --tags
  • List tags in remote branch
    git ls-remote --tags

Leave a Reply

Your email address will not be published. Required fields are marked *