如何在使用Git时在Visual Studio中刷新分支(本地/远程)? [英] How do I refresh branches (local/remote) in Visual Studio when using Git?

查看:2797
本文介绍了如何在使用Git时在Visual Studio中刷新分支(本地/远程)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总结



我正在学习如何在Visual Studio中使用Git。我最近做了一个pull请求,其中特性分支在合并后被删除。功能分支仍然显示在Visual Studio的本地和远程分支中。我知道如何右键单击并删除分支,这是一种解决方法,因为团队中的其他人可能会在我没有知道的分支上完成请求。如果他们之后删除分支,我不知道他们这样做了。



问题



你如何刷新Visual Studio分支与Git上的内容有关吗?



我期望的是什么



我希望有一个按钮,链接或右键单击功能,点击检查差异,如果发现任何问题,此分支不再存在,你想从Visual Studio中删除它吗?。

Tech Specs



我使用的是Visual Studio 2015 Enterprise

其他示例



这可能是另一个问题,但它在这里非常适合。我只注意到,如果我创建了一个分支(比如在一个虚拟机中查看与另一个虚拟机相同的回购),Visual Studio没有 git fetch 选项来更新分支名单。顶部的刷新按钮似乎没有做任何事情。只要我在bash中运行 git fetch ,visual studio就有了新的分支。如果分支已经在服务器端被删除,请尝试使用命令(因为这样的按钮似乎不直接存在于Visual Studio中):

  git remote prune origin  - 干运行

(删除 - 干运行

删除相应的本地分支以及 git branch -d aBranch 然后重新启动你的Visual Studio ,并检查它是否提取更新的分支列表。 (评论提到你不必重新启动/刷新VS)



注意:我在2013年之前提到过配置

  git config remote.origin.prune true 

code>

这会自动执行该过程,并且似乎是支持的Visual Studio ,如 亚历山大


Summary

I am learning how to use Git with Visual Studio. I recently did a pull request where the feature branch was deleted after the merge. The feature branch still shows up in my local and remote branches in Visual Studio. I know how to right click and delete the branch, this is a workaround as others on the team may complete a pull request on a branch that I have without me knowing it. If they delete the branch afterwards I would not know they did so.

Question

How do you refresh Visual Studio branches with what is on Git?

What I expect

I would expect a button, link, or right click feature that on click checks for differences, if any are found it asks, "This branch no longer exists, would you like to remove it from Visual Studio?".

Tech Specs

I am using Visual Studio 2015 Enterprise

Additional Example

This could be another question, but it fits so well here. I just noticed that if I create a branch (say in one VM and look at the same repo with another), Visual Studio does not have a git fetch option to update the branch list. The refresh button at the top does not seem to do anything. As soon as I run git fetch in a bash, visual studio has the new branch. I would expect the refresh to take care of this.

解决方案

If the branch has been deleted on the server side, try in command line (since such a "button" doesn't seem to exist directly in Visual Studio):

git remote prune origin --dry-run

(remove the --dry-run option to actually delete the local branches)

Delete the corresponding local branch as well git branch -d aBranch.

Then restart your Visual Studio, and check it picks up the updated branch list. (comments mention you don't have to restart/refresh VS)

Note: I mentioned before in 2013 the configuration

git config remote.origin.prune true

That would automate that process, and seems to be supported by Visual Studio, as mentioned below by yaniv.

这篇关于如何在使用Git时在Visual Studio中刷新分支(本地/远程)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆