gitpractice.dev

brewly — Ch.7 · Two folders at once

Exercise 6 of 6

Before you start

Worktrees

A worktree is a second folder for the same repository, with its own files and its own branch. Commits and branches are shared, so nothing needs copying.

One branch can be checked out in only one folder. cd moves you between the folders; the buttons above the files do the same.

Make sure you are in the new folder before you press "Write the code".

git worktree add ../<folder> <branch>
create a folder with that branch
cd ../<folder>
go into it
git worktree list
show every folder
git commit -am "What you did"
commit the fix
git push
ship it
git worktree remove ../<folder>
delete a folder you are done with
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path