Created
September 22, 2016 17:50
-
-
Save SpainTrain/e555a17a34ed39267b1b17dadeed5b72 to your computer and use it in GitHub Desktop.
Checkout a new branch in a git worktree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GIT_REPO_NAME=$(basename `git rev-parse --show-toplevel`) | |
BRANCH_NAME=${1} | |
WORKTREES_DIR="${HOME}/worktrees" | |
mkdir -p ${WORKTREES_DIR}/${GIT_REPO_NAME} | |
git branch ${BRANCH_NAME} | |
git worktree add ${WORKTREES_DIR}/${GIT_REPO_NAME}/${BRANCH_NAME} ${BRANCH_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment