Git:不能在分支之间切换 [英] Git: can't switch between branches

查看:250
本文介绍了Git:不能在分支之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个包含多个文件的本地文件夹中,我有一个git存储库,该分支的 x 仅包含其中一些文件,而 master 则包含了所有文件。

In a local folder with several files, I have a git repository for which branch x only includes a few of those files, and the master one includes them all.

当我尝试从x切换为master时,我得到:

When I try to switch from x to master, I get:

$ git checkout master
error: The following untracked working tree files would be overwritten by checkout:
[...some files...]
Aborting

编辑:
列出的文件都不属于分支x,它们都属于主文件。我非常有信心他们没有被修改,无论如何我都可以回到主分支中保存的任何版本。

None of the listed files belong to branch x, they all belong to the master one. I'm pretty confident they haven't been modified and in any case I am ok with going back to whatever version of them is saved in the master branch.

应该怎么办

推荐答案

您有一些文件(列出的文件)已经过编辑,但是通过检出另一个分支,您将覆盖(丢失)这些编辑。

You have some files (the ones listed) that have been edited, but by checking out a other branch, you'll overwrite (and lose) these edits.

您可以提交这些更改,也可以存储它们。

You can commit these changes, or stash them.

请参阅: http://git-scm.com/book/en/v1/Git-Tools-Stashing

这篇关于Git:不能在分支之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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