# Compare Different Branches In Visual Studio Code

In this post, I'll show how to search and compare different branches in VS Code. This is an easy and straight forward procedure using a Vscode extension.

## Shortest Way

```plaintext
git diff master..feature
```

## Smart Way

In this method, we're using a Vscode extension called Gitlens to search and compare two branches. You can use the same method for comparing two commits.

Requirement

* VS Code : [https://code.visualstudio.com/download](https://code.visualstudio.com/download)
    
* Gitlens (Extension): [https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656552385734/KooB0--6-.png align="left")

## How it Works GIF

![Gitlens-Search & compare.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1656552680384/0_qz0xTVt.gif align="left")

## Step by step

1. Click Source Control & select SEARCH & COMPARE from your VS Code
    
2. Click on Compare References
    
3. Select the branches you want to compare
    
4. Now, you can compare the files from the different branches
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656552973066/0QGETlfdB.png align="left")

Feel free to reach out to us for any [website or software development needs](https://makeinfo.co/services/website-development-service). If you enjoyed our content, don’t forget to explore [our products](https://makeinfo.co/products) as well!

References

* [How To Compare Two Git Branches](https://devconnected.com/how-to-compare-two-git-branches/)
    
* [How to compare different branches in Visual Studio Code](https://stackoverflow.com/questions/42112526/how-to-compare-different-branches-in-visual-studio-code)
    

Let's connect,

* [Follow on Twitter](https://twitter.com/themakeinfo)
    
* [Checkout our YouTube Channel](https://www.youtube.com/channel/UCIEjc-fjKyJ0MNZhK94Ehcw)
    
* [Makeinfo Products](https://www.makeinfo.co/)
