在中止git中的当前更改后切换分支 [英] Switching a branch after aborting current changes in git

查看:267
本文介绍了在中止git中的当前更改后切换分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个git repo,然后开始在其主分支中玩耍。过了一段时间,我想忽略我刚刚做出的更改(不提交它们),并切换到另一个分支。但是,它阻止我切换,因为有未提交的更改。我怎么忽视它们而不把它们藏起来呢?这是发生了什么:

I cloned a git repo and then started playing around in its master branch. After a while, I want to ignore the changes I just made (without committing them), and switch to a different branch. However, it stops me from switching because there are uncommitted changes. How do I ignore them without stashing them either? This is what happens:

$ git checkout gh-pages
error: Your local changes to the following files would be overwritten by checkout:
        somefile.txt
Please, commit your changes or stash them before you can switch branches.
Aborting


推荐答案

选项1

git checkout -f gh-pages

选项2

git reset --hard     # beware: don't make that a habit
git checkout gh-pages

这篇关于在中止git中的当前更改后切换分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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