git 无法使用 rebase 拉取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18852210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot pull with rebase
提问by guettli
I get this message:
我收到这条消息:
Cannot pull with rebase: You have unstaged changes.
Please commit or stash them.
Yes, I have changes which are not committed. I searched a way to rebase my uncommitted changes on top of the new code which I would get from a pull.
是的,我有未提交的更改。我搜索了一种方法,将我未提交的更改重新绑定到我从 pull 中获得的新代码之上。
I found this: https://github.com/aanand/git-up
我发现了这个:https: //github.com/aanand/git-up
I want to know if this is still the way to go, or if there are more modern ways to go.
我想知道这是否仍然是要走的路,或者是否有更现代的路要走。
I use git version 1.8.1
我使用 git 版本 1.8.1
采纳答案by guettli
You can use the Python port of git-up: https://github.com/msiemens/PyGitUp
可以使用git-up的Python端口:https: //github.com/msiemens/PyGitUp
pip install git-up
回答by VonC
git-upis probably the more sophisticated way to solve this issue.
Otherwise, you need to stash, rebase and stash pop.
git-up可能是解决这个问题的更复杂的方法。
否则,您需要 stash、rebase 和 stash pop。
The "more modern way" will be available in git 1.8.5 (or 1.9, Q4 2013).
As I mention in "Git - How to edit old (not previous) commit with some of the unstaged changes from current index (current state)?":
“更现代的方式”将在 git 1.8.5(或 1.9,2013 年第四季度)中提供。
正如我在“ Git - 如何使用当前索引(当前状态)中的一些未暂存更改来编辑旧的(不是以前的)提交?”中提到的:
"
git rebase
" learned "--[no-]autostash
" optionto save local changes instead of refusing to run (to which people's normal response was to stash them and re-run).
"
git rebase
"learned"--[no-]autostash
" 选项来保存本地更改而不是拒绝运行(人们的正常反应是隐藏它们并重新运行)。
Since Git 2.9 (June 2016), you now have (as commented by artofwarfare):
自 Git 2.9(2016 年 6 月)以来,您现在拥有(如artofwarfare所评论):
git pull --rebase --autostash
回答by eoconnell
You can't really "rebase" your uncommitted changes since git does not know about them yet. You should stash your local changes before you run git pull --rebase
then apply them back.
由于 git 还不知道它们,因此您无法真正“重新设定”未提交的更改。您应该在运行之前存储本地更改,git pull --rebase
然后再应用它们。
回答by Alexis N-o
I answer a little late but maybe that can be useful for someone.
我回答得有点晚,但也许这对某人有用。
If you are just looking for a one-liner to execute stash / pull rebase / stash pop
, you can create an alias.
如果您只是在寻找单行执行stash / pull rebase / stash pop
,您可以创建一个别名。
git config --global alias.spr '!f(){ git stash && git pull --rebase && git stash pop; };f'
This creates an alias named spr
that does the three operations and allows you to quickly pull --rebase
while you have unstaged changes.
这将创建一个名为的别名spr
,用于执行三个操作,并允许您在未pull --rebase
暂存更改时快速执行。
git spr