Skip to content

Instantly share code, notes, and snippets.

@michaeloyer
Created November 20, 2020 15:57
Show Gist options
  • Save michaeloyer/169a4125011b1277e20d010e87c8ce78 to your computer and use it in GitHub Desktop.
Save michaeloyer/169a4125011b1277e20d010e87c8ce78 to your computer and use it in GitHub Desktop.
Git Worktree Setup in Powershell + Git
git init SomeRepo #creates a folder in your current directory called 'SomeRepo'
pushd SomeRepo
git commit -m 'EMPTY' --allow-empty #branching doesn't work without a commit in the repo
git branch regular-branch
git worktree add -b worktree-branch '../SomeRepo#worktree-branch' #folder name example, without -b {BranchName} will create a branch with the name of the directory specified
git branch --list
popd
ls | select -exp Name
<#
Output:
Initialized empty Git repository in ./SomeRepo/.git/
[master (root-commit) 45181d7] EMPTY
Preparing worktree (new branch 'worktree-branch')
HEAD is now at 45181d7 EMPTY
Branches:
* master
regular-branch
+ worktree-branch
Directories:
SomeRepo
SomeRepo#worktree-branch
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment