3

I am very new to git and I gave GitHub integration in Visual Studio 2017. Everything is going well so far but whenever I do a pull request and merge branches I will delete the unused branch after the merge is complete on the web client. This works well but in Visual Studio, the branch I have deleted does not go away. I've seen other questions about this and the most common answer is to run the command git config remote.origin.prune true so when a fetch or pull is performed the repository will automatically prune the appropriate branches.

While I have no doubt that this will work I just don't know where to be running this. I've already tried running that in the windows CMD under the repository path (after right-clicking the repository in Visual Studio and selecting "open in Command Prompt") and it didn't throw any errors but also didn't seem to do anything at all after I ran through creating and merging another branch.

UPDATE: After looking into it a bit more I've realised the REMOTE/ORIGIN branch is being deleted but not the local one.

TestEdits does not exist on GitHub anymore

Is there a way to delete the branch locally automatically to match the remote?

NickHallick
  • 239
  • 1
  • 7
  • 24
  • _"the branch I have deleted does not go away"_ - locally, or on origin? You'll have to explicitly delete it on origin. – CodeCaster Oct 20 '17 at 12:05
  • So upon further testing, the branch will be deleted on the remote but not locally. I'm using the GitHub website to perform all my merges and deletes of branches – NickHallick Oct 20 '17 at 12:08

1 Answers1

4

As mentioned here, the prune option would only remove (on fetch) "remote tracking branches" (ie, branches defined in the refs/remotes namespace).
Meaning that branches deleted on the server side would also be deleted locally only for refs/remotes branches.

The local branches would still remain.
You still have to remove them, using command-line:

git branch --merged master | grep -v '^[ *]*master$' | xargs git branch -d
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Well, thats slightly annoying but I guess I'll just have to live with it. I can also remove the local branches by just right clicking on them in VS and selecting delete which isn't too bad but I was hoping for a more automated solution! – NickHallick Oct 23 '17 at 12:47
  • @NickHallick I agree, this is not very convenient. Maybe there is a possibility to define a custom command/shortcut in Visual Studio itself. – VonC Oct 23 '17 at 13:20