Git Worktree Operations: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 15: | Line 15: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
git worktree add -b temp-emergency-branch ../playground-temp /existing/task/branch/I/need/to/work/on | git worktree add -b temp-emergency-branch ../playground-temp /existing/task/branch/I/need/to/work/on | ||
</syntaxhighlight> | |||
To interact with the newly checked out branch in the new working tree, simply go to the worktree directory: | |||
<syntaxhighlight lang='bash'> | |||
cd ../playground-temp | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 22:04, 10 July 2020
Internal
Typical Working Tree Workflow
Assuming that a developer is in the middle of a major refactoring on a branch and it is impractical to commit a stable checkpoint, or even stash, switching to a different branch while leaving the current branch in the state it is in involves:
git worktree add ../playground-temp /existing/task/branch/I/need/to/work/on
It is also possible to create a new branch on-the-fly. The branch is based on the branch specified in command line:
git worktree add -b temp-emergency-branch ../playground-temp /existing/task/branch/I/need/to/work/on
To interact with the newly checked out branch in the new working tree, simply go to the worktree directory:
cd ../playground-temp