Michael
Michael

Reputation: 102

How to compare git branches in VS code with editing option?

Is there an option in VS code/GitLens to compare the current branch with other branch while allowing to edit the current branch in the comparison view (like when viewing unstaged changes in source control)?

Upvotes: 6

Views: 8375

Answers (4)

Franky1
Franky1

Reputation: 484

All the mentioned VSCode extensions did not work as expected for me. Therefore i went for a simple solution: I checked out the two branches into two different folders and ran the GUI tool WinMerge on these two folders.

Upvotes: 0

SilentGuy
SilentGuy

Reputation: 2203

Gitlens opens the file in a read-only diff view which doesn't allow editing. You can't jump to references from this view.

You should use git-tree-compare . You can set the base branch and see all the changes in a tree format. When you open a file, it opens the file in a regular editor with all the changes highlighted. You can use all editor features in this case.

Upvotes: 1

WL7447
WL7447

Reputation: 39

Do you want to compare your local checkout with another branch? If so, this can be done with the GitLens extension. Once installed, press F1, search for "GitLens: Compare Working Tree with ...". This will give you a list of branches to compare with. After selecting a branch, the comparisons can be seen by selecting a file in the SEARCH & COMPARE area of the SOURCE CONTROL window. You can then see the differences and edit the current file.

Upvotes: 3

Yasin Br
Yasin Br

Reputation: 1799

I highly recommend you to use: Git History

It supports all features that you mentioned.

Upvotes: 2

Related Questions