从多个分支重新创建Git仓库

时间:2023-02-05 15:25:56

I have a Git repo that has been acting funny.

我有一个很有趣的Git回购。

I can checkout all of my branches, I can work on each of them normally, and I can perform gitk to each one and view their individual commits successfully — with one exception...

我可以检查我的所有分支,我可以正常处理它们,我可以对每个分支执行gitk并成功查看它们各自的提交 - 有一个例外......

.... there is one branch that I can't seem to access. With any action I try to perform that includes the flawed branch, I receive an error.

....有一个我似乎无法访问的分支。对于我尝试执行的任何操作,包括有缺陷的分支,我收到错误。

For example: gitk --all yields fatal: blah blah blah (as a side note, more details about the error can be viewed here, but I am trying to come by a solution from a totally different angle).

例如:gitk --all产生致命:blah blah blah(作为旁注,关于错误的更多细节可以在这里查看,但我试图从一个完全不同的角度来解决)。

The Question

Is there a way to recombine all of the other, working branches together such that I can use this repo again — only losing the commits from the broken branch since the broken branch does not have any other branches extending from it?

有没有办法重新组合所有其他工作分支,以便我可以再次使用这个仓库 - 只是因为破碎的分支没有任何其他分支延伸而从丢失的分支中丢失提交?

1 个解决方案

#1


0  

You could create a remote and push all your 'good' branches onto that remote. Then in a new local directory, do a git clone of that remote.

您可以创建一个遥控器并将所有“好”分支推送到该遥控器上。然后在新的本地目录中,执行该远程的git克隆。

After that, if you do git branch -a you should see all your local and remote branches. You can create a local tracking branch for each remote branch with:

之后,如果您执行git branch -a,您应该会看到所有本地和远程分支。您可以使用以下命令为每个远程分支创建本地跟踪分支:

    git checkout -b branch remote/branch

After this, you should have a local repo with all 'good' branches.

在此之后,您应该拥有一个包含所有“好”分支的本地仓库。

#1


0  

You could create a remote and push all your 'good' branches onto that remote. Then in a new local directory, do a git clone of that remote.

您可以创建一个遥控器并将所有“好”分支推送到该遥控器上。然后在新的本地目录中,执行该远程的git克隆。

After that, if you do git branch -a you should see all your local and remote branches. You can create a local tracking branch for each remote branch with:

之后,如果您执行git branch -a,您应该会看到所有本地和远程分支。您可以使用以下命令为每个远程分支创建本地跟踪分支:

    git checkout -b branch remote/branch

After this, you should have a local repo with all 'good' branches.

在此之后,您应该拥有一个包含所有“好”分支的本地仓库。