17

After we move from TFS VC to Git as the repository on our VSO subscription, we got the following cenario.

From a given remote repository on VSO named "RepoA", after the initial clone, it presents on team explorer to me the "main" branch for this repo.

Then I created a branch "myBranch" from the "main" branch locally. Made some changes to the code, and then commit > Publish the branch to VSO.

Now if I go to VSO portal, on the code tab, I can see "myBranch" along with "main" branch there.

So, if someone else on my team clone the "RepoA" or if they already had it cloned, they fetch from team explorer, they will see the remote branchs on Branchs topic at team explorer. That is ok...

Now, if I go to the VSO portal, and open a Pull Request from "myBranch" -> "master", someone review it, approve it, click on Complete request and then click on Delete source branch, the branch will disappear from server(which is the expected behavior by click on that button).

The problem is that if I fetch changes, the branch does not desappear from my local branches(the blue circle) neither from remotes/origin(the branches on the red circle) on team explorer/branches guide.

team explorer git

What we need is, when someone delete a remote branch on VSO (the branches on the red circle) they need to be removed automatically(or by fetch command) from the remotes/origin "folder" on team explorer.

We know that local branches(the blue circle) must be deleted manually, so, how to keep Team Explorer synced with the changes made by me and others on VSO portal while using Git as repository?

If this is by design of Git "way" and its my Git nubish, please let me know and I'll definetivelly open a feature request on VSO/VS teams user voice to have something "extra" implemented on team explorer the same way it has the "Sync" button which is a VS feature, not a Git one.

Thanks! Really appreciate any help, clarifications.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Gutemberg Ribeiro
  • 1,533
  • 1
  • 21
  • 45
  • Local branches usually are not deleted when their corresponding remote is deleted. What is the problem then? – Tim Biegeleisen Jul 14 '15 at 01:38
  • By local, I mean the branch that appear on remotes/origin on my Team Explorer... Sorry the confusion, let me update the question... – Gutemberg Ribeiro Jul 14 '15 at 01:50
  • What is `remotes/origin` ? Is this a local branch or is it a branch on the remote? Your wording is _very_ unclear. – Tim Biegeleisen Jul 14 '15 at 01:53
  • OK this is clearer. The answer is that you have to manually delete the local branch. This is typical workflow in Git. – Tim Biegeleisen Jul 14 '15 at 01:56
  • Sorry for the confusion @TimBiegeleisen I added an image for the sake of clarity. Is your answer still the same? Do I need to delete the branches under remotes/origin manually on team explorer even if they was already deleted from VSO? In case of yes, please add you reply as an answer so I can mark it in case noone else has any workaround. Thanks – Gutemberg Ribeiro Jul 14 '15 at 03:23
  • I have never used your version control system, but based on the diagram it appears this is showing the remote branches on the GitHub repo which are being tracked. In this case, I think the problem might be that this list is not being updated. Can you force an update of some sort? – Tim Biegeleisen Jul 14 '15 at 04:46
  • @TimBiegeleisen VSO stands for Visual Studio Online from Microsoft, which a hosted TFS(Team Foundation Server) in Microsoft Azure. It supports both TFS VC or Git as the source control repository and has several benefits as builds, boards for task management, test suites(automatic and manual), deployment etc. The answer bellow does exactly what we need. For more on VSO, take a look here: https://www.visualstudio.com/products/what-is-visual-studio-online-vs Thanks! – Gutemberg Ribeiro Jul 14 '15 at 17:34
  • And for the sake of information, VSO does A LOT more than just code repository as GitHub. Today, if you are working on a commercial project or it does not requires community contribution and you need a full ALM(Application Lifecycle Management) solution, I would go with VSO but, if you need community contribution and/or is an open source project, you can just keep GitHub since it doesn't have limits on free contributions but remember that GitHub is just a hosted Git, nothing more. – Gutemberg Ribeiro Jul 14 '15 at 17:39

1 Answers1

29

What you are looking for is for the fetch command to also prune, but this is not supported at present in VSO. As a workaround, you can configure git to always prune by default whenever you do a git fetch. You can do this using git config remote.origin.prune true

See this thread for details, Automatic prune with git fetch or pull

Also, it might help if you can upvote the below feature request at user voice :-)

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/7204022-visual-studio-git-propose-to-prune-when-fetchi

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/7744350-add-pruning-of-a-git-remote-to-the-team-explorer

Community
  • 1
  • 1
Techtwaddle
  • 1,643
  • 1
  • 15
  • 11
  • Thanks for the solution/workaround @Techtwaddle, this is exactly what we need. I did upvote on the user voice, I hope MS add at least a checkbox on Sync pad of Team Explorer or another button (fetch+prune) or let the user check it on its Settings for the repo or global. Thank you very much! – Gutemberg Ribeiro Jul 14 '15 at 17:26