-1

My master branch is currently syncing with a local folder W:\folder2.

I'd like my master branch to sync with local folder W:\folder1 instead.

How can I do this?

I was playing around, while learning, in GitShell with git worktree add <second path> and git checkout master and git checkout -b <new branch> commands.

Before, my master branch was synced with local folder W:\folder1.
Now it's synced with local folder W:\folder2.

I think I accidentally switched something.

How do I switch it back?

codr
  • 889
  • 3
  • 13
  • 22

1 Answers1

2

git worktree

Git worktree was introduced in 2007 under the contrib folder in git repo and was called new-workdir.

In git V2.5 it was named worktree and it allow you to have multiple instances of the same repository across different folders.

for example:

git worktree add <second path>

will create another folder on your computer which allow you to work on different branch simultaneously.


If you want to remove the worktree use the prune subcommand

prune
Prune working tree information in $GIT_DIR/worktrees.

Another option to remove it is to delete the .git/worktrees folder

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
CodeWizard
  • 128,036
  • 21
  • 144
  • 167