Skip to content

Instantly share code, notes, and snippets.

@devopsmariocom
Last active September 11, 2015 17:02
Show Gist options
  • Save devopsmariocom/fe6edd28bbcdb4c872a5 to your computer and use it in GitHub Desktop.
Save devopsmariocom/fe6edd28bbcdb4c872a5 to your computer and use it in GitHub Desktop.
Checkout workintree from git to parent directory see https://git-scm.com/docs/git-worktree
#!/bin/bash
CURRENT_WORKTREE_DIR=../worktrees/${PWD##*/}
BRANCH=$1
mkdir -p $CURRENT_WORKTREE_DIR
git worktree add -b $BRANCH $CURRENT_WORKTREE_DIR/$BRANCH origin/$BRANCH
@devopsmariocom
Copy link
Author

run yourProjectName$ gwtree.sh branchName and you should find your worktree under ../worktrees/yourProjectName/branchName

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment