将 git-svn master 分支重新指向主干

发布于 2025-01-05 02:34:28 字数 270 浏览 0 评论 0原文

我不确定我是如何进入这种状态的,但我本地 git-svn 存储库上的 master 分支似乎指向远程 UAT 分支。

git status
# On branch master nothing to commit (working directory clean)
git svn dcommit Committing to https://svn...com/MyRepo/branches/UAT ...

我该如何解决这个问题?

I'm not sure how I got into this state, but my master branch on my local git-svn repo seems to be pointing to the remote UAT branch.

git status
# On branch master nothing to commit (working directory clean)
git svn dcommit Committing to https://svn...com/MyRepo/branches/UAT ...

how do I fix this?

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

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

发布评论

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

评论(2

等数载,海棠开 2025-01-12 02:34:28

我认为您要解决的问题是您的本地“主”分支基于远程 UAC 分支,而不是远程主干。如果您很高兴失去提交,您可以简单地运行下面的命令,这将检查主干,然后将主分支移动到您当前的位置。

git checkout remotes/trunk
git checkout -B master

如果您不想丢失提交,git rebase 是您的朋友。使用以下命令:

git rebase $(git merge-base remotes/UAC master) master --onto remotes/trunk

这会计算出 UAC 分支和本地 master 分支的共同父级,将所有从那里到 master 分支顶端的提交提交到主干上,然后将 master 分支移动到那里。

I think what you're trying to fix is that your local "master" branch is based on the remote UAC branch, as opposed to the remote trunk. If you're happy to lose your commits, you can simply run the below, which will checkout the trunk and then move the master branch to your current point.

git checkout remotes/trunk
git checkout -B master

If you don't want to lose your commits, git rebase is your friend. Use the below:

git rebase $(git merge-base remotes/UAC master) master --onto remotes/trunk

This works out the common parent of the UAC branch and the local master branch, makes all the commits from there to the tip of the master branch onto the trunk, then moves the master branch to point there.

谁对谁错谁最难过 2025-01-12 02:34:28

一种方法是重命名当前主分支并将 origin/trunk 签出为(新)主分支。

git branch -m master uat
git checkout origin/trunk master

如果您需要,您现在可以将cherry-pic从uac分支提交到master(我会使用gitk --all来帮助我解决这个问题)

一个更复杂的问题:
重命名本地和远程 Git 存储库的 master 分支

One way would be to rename the current master branch and to checkout origin/trunk as (new) master branch.

git branch -m master uat
git checkout origin/trunk master

If you need you can now cherry-pic commits from the uac branch to master (I would use gitk --all to help me with this)

A little more complex problem:
Rename master branch for both local and remote Git repositories

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