Created
November 20, 2020 15:57
-
-
Save michaeloyer/169a4125011b1277e20d010e87c8ce78 to your computer and use it in GitHub Desktop.
Git Worktree Setup in Powershell + Git
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
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