Skip to content

Instantly share code, notes, and snippets.

@virtualstaticvoid
Created February 23, 2011 20:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtualstaticvoid/841078 to your computer and use it in GitHub Desktop.
Save virtualstaticvoid/841078 to your computer and use it in GitHub Desktop.
Checkout single Git branch
#!/bin/bash
#
# Creates a Git repository, fetches and checks out a single branch from the remote repository
#
url=$1
branch=$2
git init
git remote add origin $url
git fetch origin $branch:origin/$branch
git checkout -b $branch --track origin/$branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment