# Using Git worktrees

**URL:** <https://bnd.discourse.group/t/using-git-worktrees/79>\
**Category:** TIPS\
**Created:** [January 20, 2021, 3:54pm UTC](https://bnd.discourse.group/t/using-git-worktrees/79 "2021-01-20T15:54:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [January 20, 2021, 3:54pm UTC](https://bnd.discourse.group/t/using-git-worktrees/79/1 "2021-01-20T15:54:04Z")

</div>

Switching between git branches can be cumbersome. They usually require a full build and there are lots of things that can go wrong. The past 10 years I regularly have 10 workspaces open at the same time, but they were on different bnd/git workspaces.

Of course it is possible to have different git workspaces on the same repository. However, that is easy to get confused. Recently I learned about git _worktrees_. They share one Git repository, well the `.git/` directory, but allow you to get the files in a different directory.

```
 master $ git worktree add ../branch feature/branch

```

Git tracks these worktrees and will warn you when you want to checkout the same branch in different places. I find it extremely useful.

---

<div class="post-metadata">

**Author:** ![castortech](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/castortech/32/15_2.png) [@castortech](https://bnd.discourse.group/u/castortech)\
**Post date:** [March 28, 2021, 4:51pm UTC](https://bnd.discourse.group/t/using-git-worktrees/79/2 "2021-03-28T16:51:57Z")

</div>

Peter, this is a fantastic tip, has saved me a lot of grief.

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [March 29, 2021, 6:55am UTC](https://bnd.discourse.group/t/using-git-worktrees/79/3 "2021-03-29T06:55:03Z")

</div>

Only drawback is that many git GUIs (including Eclipse) don’t know about this ☹ However, the command line works fine.
