Anshul Sahni
Anshul Sahni

Reputation: 666

How to browse code in source tree checked out at particular branch

How to browse files in source tree, while it is checked out at a particular branch or at a commit, without affecting anything in the original repository

Upvotes: 1

Views: 1444

Answers (1)

CodeWizard
CodeWizard

Reputation: 141946

You can use git worktree to checkout the content of the other ranch into a new folder without affecting the current branch.

git worktree

git worktree and it allows you to have multiple instances of the same repository across different folders.

The wokrtree create new folder with the content of the desired branch but your 3-states will be clean and you will have new 3-states per working folder.

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

enter image description here


If you use rebase later on:

  • Note: (Since Git 2.7)
    you can also use the git rebase [--no]-autostash as well.

Upvotes: 2

Related Questions