Have you experienced delays when viewing your Git repository or branch history in Visual Studio? Have you run a network command like force-push and had to wait for the operation to complete? Your Git repository may be having performance issues due to its large size. We are happy to integrate a relatively new Git feature called the commit graph which leads to improving the performance of your Git operations and significantly improving performance in Visual Studio.
Once you are on the latest preview version of Visual Studio (17.2 Preview 3 or later), Visual Studio will automatically show the following notification where you can choose to enable the commit graph.
Alternatively, you could manually enable the commit-graph by going to Git > Settings > Enable commit graph for better Git performance.
What happens when you enable the commit graph?
When the commit graph is enabled, a commit graph file gets generated in your repository which then is used to quickly parse and sort your commits. The commit graph file also includes extra information to help avoid parsing commits. Generating the commit graph is a background operation that could take several seconds up to couple of minutes depending on the size of your repository. It is also a blocking Git operation that will block you from performing other Git operations in Visual Studio like Fetch or Pull. View this blog to read more about how the commit graph works.
When should you consider running the commit graph?
You will see most of the value of the commit graph right after you run it for the first time. Visual Studio will only show the commit graph notification when it is not enabled, and when Visual Studio predicts that running the commit graph could enhance performance.
How to manually run the commit graph
If you did not receive the notification, you can also choose to manually re-run the commit graph at any time if you have already enabled it in Visual Studio by using the following command line or by disabling and enabling the commit graph in our Git settings Git > Settings > Enable commit graph for better Git performance.
git commit-graph write --reachable
Commit graph resources
If you are interested in learning more about the commit graph Git feature, you might find the following resources a good starting point:
- Supercharging the Git Commit Graph – Azure DevOps Blog (microsoft.com)
- Updates to the Git Commit Graph Feature – Azure DevOps Blog (microsoft.com)
- Git – commit-graph Documentation (git-scm.com)
Let us know what you think
We have benefitted greatly from all the rich feedback we’ve received from you – thank you! We hope you’ll help us continue to improve by giving the new commit-graph feature a try and letting us know what you think by taking the following quick survey:
I do not see Git > Settings > Enable commit graph for better Git performance option. Visual Studio Enterprise 2022 (64-bit) 17.2.3.
I was unable to push/pull codes to/from remote git server after updates to latest Visual Studio 2022 Community as well as Visual Studio 2022 Community Preview, It looks my local git repository has crashed.
Environment: Windows 10 Chinese, exFAT disk partition.
Try as I might, I can’t ever run Git from the command line. I’ve tried developer command prompt, Terminal, PowerShell, etc. Every time I type ‘git’, I’m told Windows doesn’t recognize it. Can you please tell me where and how to execute the git command-line statement that you mention in this article?
Does VS Code also take advantage of the commit graph? Or does VS Code ignore it?