If the folder is not empty you will see an error message the command will fail. Note: To use this option you must select an empty folder during the file section step, (step 2 in the process). vscode-gitlens-demo-1 relative to your present working directory. Letâs also assume you have selected the next highest directory to base the new worktree entryâs folder. If you select the third option from the Command Palette drop-down menu: Create Worktree (directly in folder) for branch, you will create a new worktree entry based on your specified branch inside the target folder.įor example, letâs say youâre creating a worktree entry from the insiders branch and want to have it live in a directory called vscode-gitlens-demo-1. While this is the most common, and least confusing way to name the directory, Git allows you to have a different name for the folder than the branch name. Up until now, you have named the target directory using the same name as the branch. How do you use Git worktree add for an existing branch using a different name than the working directory with GitLens? To add a new remote, navigate to the directory your repository is stored at and use the git remote add command followed by the remote name, and the remote URL: git remote add For example, to add a new remote named staging pointing to the :user/reponame.With Git worktree, you simply tell Git to checkout the feature branch in a different directory, outside your present working directory and change to that directory from here, you can do your work and change back to the original directory to find all your work in progress awaiting you, just as you left it. Instead of that stash and checkout flow, you can simply add a new worktree entry and change directory into the needed branch.įor example, imagine youâre working on a project inside the main branch, but need to test and approve changes applied in a feature branch. If that sounds inefficient, the makers of Git agree with you. What would happen if you suddenly have to work on a hotfix in another branch? For many people, the normal workflow would be to use Git stash to save your current work, checkout the hotfix branch, conclude that work, then re-checkout the branch you were originally on and pop your stash. Imagine youâre in the middle of making numerous changes on a project with multiple new dependencies introduced with various WIP changes. Now, what situations might you utilize this action? The Git worktree command allows you to checkout and work in multiple Git branches simultaneously.
0 Comments
Leave a Reply. |