Git分支不按我期望的方式工作 [英] Git branch not working the way I expected it to

查看:86
本文介绍了Git分支不按我期望的方式工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目 master 分支中,我提交了更改: git commit -a



创建&切换到新分支: git checkout -b newbranch



尝试一些内容...



意识到'东西'没有按照我认为可能切换回主人的方式工作: git checkout master 意图移动沿着那里...但意识到在newbranch中添加的一些文件仍然在TextMate中......所以...
$ b $我输入 git status 我仍然看到所有我认为留在newbranch中的东西被列在Untracked files下面。



我尝试: git reset --hard 让我回到最后一次commit ..但newbranch中的变化仍然存在?!?



我缺少什么?

解决方案

你缺少什么?那么,问题中的文件是没有跟踪的,git不会触及那些拥有10英尺杆的文件。 ;)



实际上,如果你不打算提交任何内容,可能没有理由检出新的分支。



您可以像平常一样尝试新的更改。如果你不喜欢你所看到的,但是想在以后使用新的代码,那么你可以隐藏它,就像这样:

  git存储保存一些没有解决的更改。 

如果您绝对想让它消失,您所要做的只是:

  git clean -d --dry-run 

然后确定:

  git clean -df 


In my project master branch I commit changes: git commit -a

create & switch to new branch: git checkout -b newbranch

try some stuff...

realize 'stuff' didn't work out the way I thought it might so switch back to master: git checkout master with intent of moving along from there... but realize some files added in newbranch are still in TextMate... so...

I type git status I still see all the stuff I thought I'd left in newbranch is listed under "Untracked files"

I try: git reset --hard to take me back to that last commit..but changes in newbranch still persist?!?

what am I missing?

解决方案

What are you missing? Well, the files in questions are untracked and git wouldn't touch those with a ten-foot pole. ;)

In all honestly, if you weren't going to commit anything there was probably no reason to checkout a new branch.

You could have tried the new changes as normal. If you didn't like what you saw but wanted to use the new code later, you could have stashed it, like so:

git stash save "Some changes that didn't work out."

If you absolutely wanted it gone instead, all you had to do was:

git clean -d --dry-run

and then when sure:

git clean -df

这篇关于Git分支不按我期望的方式工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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