Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, October 29, 2017 10:33 AM
Hi all;
Visual Studio continues to show any branch I've pulled, even after that branch has been deleted (and I do not have it as the selected branch).
- "git fetch --all --prune" does not remove them.
- "remote.origin.prune true" (suggested here) does not remove them.
- "git push origin --delete abranch" does not remove them.
- "git branch -avv" does not remove them
How can I remove the deleted branches from my system?
I want an approach that determines what branches are gone and deletes them. If we select them specifically then sooner or later someone will delete a branch in use by mistake.
??? - thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
All replies (11)
Monday, October 30, 2017 7:52 AM
Hi David,
Thank you for posting in MSDN forum.
Could you please express how you delete the brunch?
For VS local branch, you need to manually delete them.
For remotes/origin/branchname, once you execute the "git fetch --all --prune" command, the branch should be removed.
>>I want an approach that determines what branches are gone and deletes them.
You could compare local branch with remote/origin ones, if the branch doesn't exist in remote/origin, you can direct delete them in local.
Best Regards,
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Monday, October 30, 2017 2:56 PM
For remotes/origin/branchname, once you execute the "git fetch --all --prune" command, the branch should be removed.
As I said above, "git fetch --all --prune" does not remove them from the list in Visual Studio 2015.
You could compare local branch with remote/origin ones, if the branch doesn't exist in remote/origin, you can direct delete them in local.
As I said above "I want an approach that determines what branches are gone and deletes them. If we select them specifically then sooner or later someone will delete a branch in use by mistake."
How can I tell Visual Studio to drop all branches that no longer exist?
thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
Tuesday, October 31, 2017 9:05 AM
Hi David,
For the first question, this situation is particular. for the second question, you could write a shell script to do the compare.
As we know, this forum is about Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor your questions are related to git, I suggest you post in https://stackoverflow.com/questions/tagged/version-control+git to get a much professional support.
Thank you for your understanding.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Tuesday, October 31, 2017 4:30 PM
Hi;
I did ask on StackOverflow (see here). However, they had the same answer you did that "git fetch --all --prune" should work.
Since this should work, but VisualStudio is not operating as expected, I need help from you on how to get VisualStudio to operate as expected.
thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
Wednesday, November 1, 2017 9:48 AM
Hi David,
In order touble shooting your issue, can you provide more detail steps (listed as below) for deleting a test branch in remote and remove in VS2015 again:
1. Show the screen shot of your remote repo, and which branch you are going to delete.
2. Show the screen shot in VS2015: Team explorer -> Branches -> show the local branches and the tracking branches under remotes/origin.
3. Execute git fetch --all --prune and provide the output message
4. Show the screen shot of tracking branches under remotes/origin again in VS2015.
Best Regards,
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Wednesday, November 1, 2017 5:30 PM
Here you go:
1. How do I display the remote repo?
2. Here's the screenshot
3. Here' the Git output:
C:\git\Jenova>git fetch --all --prune
Fetching origin
remote: Microsoft (R) Visual Studio (R) Team Services
remote: We noticed you're using an older version of Git. For the best experience, upgrade to a newer version.
remote: Found 24 objects to send. (393 ms)
Unpacking objects: 100% (24/24), done.
From https://windwardstudios.visualstudio.com/\_git/Jenova
* [new branch] connor-bugfix-support-16.0 -> origin/connor-bugfix-support-16.0
* [new branch] release-16.0-20171102 -> origin/release-16.0-20171102
C:\git\Jenova>
4. How do I show this?
thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
Thursday, November 2, 2017 9:06 AM
Hi David,
Based on your screen shot and the output of the command, it seems the deleted branch has already been removed.
Assume if the branch support-15.2 was deleted in remote repo (https://windwardstudios.visualstudio.com/_git/Jenova), when you execute git fetch --all –prune, the tracking branch remotes/origin/support-15.2 (under remotes/origin) should be removed.
For the local branch support-15.2, you should remove the local branch support-15.2 manually or by script.
Best Regards
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Thursday, November 2, 2017 11:37 AM
For the local branch support-15.2, you should remove the local branch support-15.2 manually or by script.
Actually support-15.2 is our release branch. Deleting that would delete our most recent code.
This is why I am looking for a way where Visual Studio will remove from my listing all branches that have been deleted in an automated way. Because specifically deleting a branch - I might delete a branch that still exists on Git and is needed.
How can I get Visual Studio to not list branches that no longer exist?
And if you don't know the answer, can you ask someone on the Visal Studio team?
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
Friday, November 3, 2017 9:47 AM
Hi David,
For support-15.2, it’s just an example branch to explain the relation about deleted branch and the command git fetch --all --prune.
And as I mentioned above, you can only remove the related tracking branches under remotes/origin, not local branches (no matter by VS, other GUIs or command line).
The only way to remove the deleted branches from local branch is execute by script. Below is an shell script to remove deleted branches from local branches:
#!/bin/sh
git fetch -p
#checkout HEAD to the branch which you will never delete, here is master as example
git checkout master
flag="no"
for local in $(git for-each-ref --format='%(refname:short)' refs/heads/)
do
{
flag="no"
for remote in $(git branch -r)
do
{
flag="no"
if [[ $remote == "origin/HEAD" ]]; then
echo "it's HEAD"
break
fi
if [[ "origin/$local" == $remote ]]
then
{
flag="yes"
break
}
fi
}
done
if [[ $flag == "no" ]]; then
git branch -D $local
fi
}
done
Best Regards
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Monday, November 6, 2017 12:44 PM
Hi;
This is really sad if the only way you can tell Visual Studio to not display branches that no longer exist is with a script. It's something it should auto detect.
Please suggest to the Visual Studio team that they automate this.
thanks - dave
What we did for the last 6 months - Made the world's coolest reporting & docgen system even more amazing
Friday, November 10, 2017 8:56 AM
Hi David,
I have invited Microsoft senior engineer for you to solve this question.
Thank you for your understanding.
Best Regards,
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].