Is it possible that in your working project, you are using different branch that you need to update and you cannot merge in master because of some obligations (working with different clients, different teams, …). So what we want is only to update few files when we modify it on another branch.
I find out an amazing tool GitLens to compare different branches from your git project directly from the IDE (using Visual Studio Code).
You can find it in the Marketplace here is what it looks like:
After you have installed it, you will have a new tab on Visual Studio Code, in this tab you will be able to see 5 tools:
- Repositories : See on which repositories and branch you are working on
- Files History : visualize navigate and explore the revision history of current file
- Line History : visualize navigate and explore the history of the selected lines of current file
- Compare Commits : to visualize comparisons between branches, tags, commits, and more, THIS is the most interesting tool that we are going to use
- Search Commits : to search and explore commit histories
With the Compare Commits tool we can click Compare <branch, tag, or ref> and be able to compare 2 branch:
If you click on a commit or a file, you will be in read only mode. To modify your file side by side you will have to click on a button.
This button is Compare with HEAD here is where is it located:
You can now compare and modify the file side by side, what you cannot do with Visual Studio in a single branch.