简体   繁体   English

在 Visual Studio 中从过去的提交创建新的 git 分支时,如何处理数组越界异常?

[英]How do I deal with the array out of bounds exception when creating a new git branch from a past commit in Visual Studio?

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.偏移量和长度超出数组范围或计数大于从索引到源集合末尾的元素数。

This is what I get in the Team Explorer tab when I try to create a new branch to one of the previous commits.当我尝试为以前的提交之一创建新分支时,这就是我在“团队资源管理器”选项卡中得到的结果。 I've had this error happen in the past, and updating to the most recent version of VS 2017 (15.9.7) just now made no difference.我过去发生过这个错误,现在更新到最新版本的 VS 2017 (15.9.7) 没有任何区别。 In the past the only way I've managed to get around this problem is by branching out to some other commit, but now this really hit me where it hurts.过去,我设法解决这个问题的唯一方法是扩展到其他一些提交,但现在这真的让我感到痛苦。

Using git checkout from the command line worked for me.从命令行使用git checkout对我有用。

More specifically, git checkout <commit> -b temp where <commit> is the commit id.更具体地说, git checkout <commit> -b temp其中<commit>是提交 ID。 What this did is create a branch named temp similarly to how it would be done using the IDE.这所做的是创建一个名为temp的分支,类似于使用 IDE 的方式。

I have no idea why this error occurs for me, but while looking at similar issues I noticed that people managed to get around using git commands from the command line.我不知道为什么会出现这个错误,但在查看类似问题时,我注意到人们设法从命令行使用 git 命令。 It worked fine enough here.它在这里工作得很好。

It's due to overload of commits cache in local, since it's specific to Visual Studio这是由于本地提交缓存过载,因为它特定于 Visual Studio

  • Option 1 : use git bash git checkout选项 1:使用 git bash git checkout
  • Option 2 : Take a local repo backup, delete it and clone it one more time选项 2:进行本地 repo 备份,将其删除并再克隆一次

I had this error and I made the following steps: Go to: Visual Studio -> Team Explorer -> Branches Step 1: Remove the local Branches that you do not need any more Step 2: on each remaining local Branches I right click and select Reset -> Delete changes (hard)我遇到了这个错误,我做了以下步骤:转到:Visual Studio -> 团队资源管理器 -> 分支步骤 1:删除不再需要的本地分支步骤 2:在每个剩余的本地分支上,我右键单击并选择重置 -> 删除更改​​(硬)

Probably not need existing changes once you start to work on another branch.一旦您开始在另一个分支上工作,可能不需要现有的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM