在特定的遥控器,分支和提交上的git rebase

发布于 2025-02-05 03:09:51 字数 613 浏览 3 评论 0原文

The situation is:

I've got a local git repo with no set remotes. I want to add a remote for a specific branch, which a believe I can do like this:

git remote add New_Remote -t -f {New_Remote_Branch} {Repo}

I then want to rebase my local git repo不仅是new_remote_branch的负责人,而且要涉及它的特定提交。我已经阅读了文档,并且已经看过- 在选项上,但是我对如何将其定位到特定的遥控器和提交有点困惑。我在测试这个概念并找到语法方面遇到了麻烦。 I believe I'm looking for something like:

(from the local repo directory)

git rebase New_Remote/New_Remote_Branch --onto {New_Remote_Branch_Specific_Commit_id}

The situation is:

I've got a local git repo with no set remotes. I want to add a remote for a specific branch, which a believe I can do like this:

git remote add New_Remote -t -f {New_Remote_Branch} {Repo}

I then want to rebase my local git repo not just to the HEAD of New_Remote_Branch but to a specific commit of it. I've read the docs and I've seen the --onto option but I'm a bit confused about how to target it to a specific remote and and commit. I've had trouble testing this concept and finding the syntax. I believe I'm looking for something like:

(from the local repo directory)

git rebase New_Remote/New_Remote_Branch --onto {New_Remote_Branch_Specific_Commit_id}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烂柯人 2025-02-12 03:09:51

git rebase的完整语法是:

git rebase --onto $new_upstream $old_upstream $branch_to_rebase

它将在old_upstream和branch_to_rebase之间进行所有提交,并在new_upstream上重新创建它们。最后,“ branch_to_rebase” ref将指向重新创建的最新提交。

所有三个参数都可以是分支,标签或提交。最后一个通常应该是分支,否则您最终会以脱离的头状态(但很容易恢复)。前两个论点只需要解决提交。

,在您的情况下,您的命令看起来像:

git rebase --onto $specific_commit_id master your_branch

因此

The full syntax of git rebase is:

git rebase --onto $new_upstream $old_upstream $branch_to_rebase

It will take all commits between old_upstream and branch_to_rebase and recreate them on top of new_upstream. In the end, the "branch_to_rebase" ref will point to the newest of the recreated commits.

All three arguments can be a branch, tag, or commit. The last one should usually be a branch, otherwise you end up in detached HEAD state (but it's easy to recover). The first two arguments only need to resolve to a commit.

So in your case, your command will look something like:

git rebase --onto $specific_commit_id master your_branch

(assuming that you want to copy all commits on your branch that were created since master)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文