How to Configure Git in Visual Studio to Prune Branches during a Fetch

January 2, 2018

If you’ve been using Git from within Visual Studio 2017 you might be aware of the fact that when performing a fetch it would not automatically prune your local list of branches that no longer exist on the server. Typically you would have to open up a Command Prompt and run the following command to cleanup your list of branches that exist on the remote:

> git remote prune origin

image

Well now with Visual Studio 2017 Update 5 you can now configure your global and repository settings to prune your local list of branches on every fetch. Let’s take a look at how you can configure this.

First download and install Visual Studio 2017 Update 5. You can do this from within Visual Studio under the Tools menu:

image

Once you have Visual Studio 2017 Update 5 installed, go to the Team Explorer pane and click on Settings where you can configure your default behavior for your Global and/or Repository Settings:

image

image

Now you can change the setting to prune remote branches on every fetch. In my opinion this should be the default value.

image

Another nice addition to the Git settings in Visual Studio 2017 Update 5 is the ability to Rebase your changes when you pull. I’ll explore that in a future post.

In summary when enabling the prune on every fetch, this means your local list of branches is always up-to-date with the remote. Pruning will cleanup and remove your local tracking branches that no longer exist on the server.

Enjoy!

References

Git Configuration: Configure your default behavior

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Karim Vaes

The insights of a Quirky Cloud Solution Architect on his journey through the fast paced IT landscape.

Software Engineering

Web development

PowerShell, Programming and DevOps

Musings and mischief on PowerShell, Programming and DevOps.

toon vanhoutte

Blogging about connecting devices, systems and people! On-premises and in the cloud. Microsoft stack only.

Ken Cenerelli

My life in software development

STEFANROTH.NET

Things about cloud and management

Build HoloLens

All about HoloLens

DevDays®

For web designers and cloud developers

Build Azure

All about the Microsoft Cloud

vishal patel

Software Developer, Windows 8 and Windows Phone Enthusiast

SQL with Manoj

SQL Server (TSQL) Programming, DB concepts, Tips & Tricks with >500 articles... comments welcome!!!

dragablz.wordpress.com/

Dragable, tearable, dockable WPF TabControl. Open source to boot.

Adrian Hall

Because Developers are Awesome

Ratish Philip's Blog

Another adventure in code...

codematrix

Application Architecture at it's best

One Unicorn

Thoughts from one member of the Entity Framework team...

Rachel Lim's Blog

Simplifying programming into something I can understand

.NET Developer's Blog

Software Development, Flying and Life

The Flying Maverick

Software Development, Flying and Life

%d bloggers like this: