如何将Git的交互式rebase与仅限本地的存储库(没有远程/源)一起使用?

时间:2015-06-03 16:03:22

标签: git branch rebase git-rebase remote-branch

我使用git作为本地源代码控制系统,主要用于历史记录和差异跟踪。我仍然希望使用rebase来对我将定期制作的WIP提交进行修复/压缩。当我尝试git rebase -i时,我得到以下内容:

There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-rebase(1) for details

    git rebase <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> MyBranch

似乎git并不期望你在没有上游遥控器的情况下使用交互式rebase?我该怎么做?

2 个答案:

答案 0 :(得分:29)

git rebase -i简写,没有指定目标分支,将使git假设您正在尝试对您的分支跟踪的远程分支进行rebase。这就是错误消息提到遥控器的原因。

当您指定目标时,git会针对commit-ish

进行重新定位
git rebase -i <commit-ish>

答案 1 :(得分:16)

所以简而言之 - 如果你有3个本地提交,你现在想要以交互方式变换/压缩/等等它们:

git rebase -i HEAD~3

(见塞巴斯蒂安的解释!)

相关问题