我如何使用Git的交互式rebase与本地存储库(无远程/本地)? [英] How do I use Git's interactive rebase with a local-only repository (no remote / origin)?
问题描述
我使用git作为本地源代码控制系统,主要用于历史记录和差异追踪。我仍然想使用rebase来修改/挤压WIP提交,我会定期进行。当我尝试做 git rebase -i
时,我得到以下结果:
I use git as a local source control system mostly for history and diff tracking. I still want to use rebase to do fixup / squash on WIP commits that I will make periodically. When I try to do git rebase -i
though, I get the following:
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?如何做到这一点?
It seems like git doesn't expect you to use interactive rebase without an upstream remote? How do I do that?
推荐答案
git rebase -i
,但没有指定目标分支,将使git假定你正试图对你的分支跟踪的远程分支进行重新分配。这就是为什么错误消息提到了关于远程的东西。
git rebase -i
in shorthand, without specifying a destination branch, will make git assume that you are trying to rebase against a remote branch tracked by your branch. That's why the error message is mentioning stuff about remotes.
当你指定一个目标时,git会根据该commit-ish进行rebase:
When you do specify a target, git will rebase against that commit-ish:
git rebase -i <commit-ish>
这篇关于我如何使用Git的交互式rebase与本地存储库(无远程/本地)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!