错误:无法使用 rebase 拉取:您有未暂存的更改 [英] Error: Cannot pull with rebase: You have unstaged changes

查看:543
本文介绍了错误:无法使用 rebase 拉取:您有未暂存的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始与几个朋友在一个项目上合作 &他们使用 heroku git 存储库.

I have started collaborating with a few friends on a project & they use the heroku git repository.

几天前我克隆了存储库,此后他们进行了一些更改,因此我正在尝试获取最新更新

I cloned the repository a few days ago and they have since made some changes so I am trying to get the latest updates

我按照此处所述运行了 git pull --rebase 命令(这是正确的方法吗?):https://devcenter.heroku.com/articles/sharing#merging-code-changes

I ran the git pull --rebase command as stated here(Is this the right way to do it?): https://devcenter.heroku.com/articles/sharing#merging-code-changes

我收到以下错误:

$ git pull --rebase
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.

我的猜测是我把代码弄乱了,现在它要我提交或丢弃(这是 stash 意味着什么?)更改.这是正在发生的事情吗?如果是这种情况,我想放弃我可能所做的任何更改,只从 git 存储库中获取更新的代码.

My guess is that I messed around with the code and now it wants me to either commit or discard(is that what does stash means?) the changes. Is this what is happening? If this is the case I would like to discard any changes I might have made and just get the updated code from the git repository.

知道我能做什么吗?

推荐答案

Do git status,这将显示哪些文件发生了更改.由于您表示不想保留更改,您可以执行 git checkout -- <file name>git reset --hard 来摆脱变化.

Do git status, this will show you what files have changed. Since you stated that you don't want to keep the changes you can do git checkout -- <file name> or git reset --hard to get rid of the changes.

在大多数情况下,git 会告诉您如何处理更改.例如,您的错误消息说 git stash 您的更改.如果你想保留它们,这将是.拉取后,您将执行 git stash pop 并重新应用您的更改.

For the most part, git will tell you what to do about changes. For example, your error message said to git stash your changes. This would be if you wanted to keep them. After pulling, you would then do git stash pop and your changes would be reapplied.

git status 还具有如何根据文件是否暂存以进行提交来摆脱更改的方法.

git status also has how to get rid of changes depending on if the file is staged for commit or not.

这篇关于错误:无法使用 rebase 拉取:您有未暂存的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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