如何重置git远程跟踪分支?

时间:2021-12-08 07:23:48

In another question it was recommend that I try resetting a remote tracking branch to an earlier commit and performing an import a second time. I can't figure out how to do that! I can reset master, but not the branch master is tracking, cvs/master.

在另一个问题中,建议我尝试将远程跟踪分支重置为先前的提交并再次执行导入。我无法弄清楚该怎么做!我可以重置master,但不是分支master正在跟踪,cvs / master。

If I check out cvs/master, I'm not on a branch, so git-reset basically has no effect.

如果我检查cvs / master,我不在分支上,所以git-reset基本上没有效果。

How do I change the commit to which cvs/master (or any arbitrary remote tracking branch) refers?

如何更改cvs / master(或任意远程跟踪分支)引用的提交?

2 个解决方案

#1


git-cvsimport remote branches are kind of faked out so I think you can just edit the appropriate file in your .git directory (.git/refs/remotes/cvs/master in this case) and put the appropriate commit I'd in the file. I'm not sure if this will fix the problem in your other question though...

git-cvsimport远程分支有点伪造,所以我认为你可以只编辑.git目录中的相应文件(在这种情况下为.git / refs / remotes / cvs / master)并将相应的提交放入文件。我不确定这是否可以解决你的另一个问题...

#2


Did you try this: create a local branch that targets that remote branch, reset or rebase this local branch to your needs, push the local branch with -f option (force)?

您是否尝试过这样做:创建一个针对该远程分支的本地分支,根据您的需要重置或重新定位此本地分支,使用-f选项(强制)推送本地分支?

#1


git-cvsimport remote branches are kind of faked out so I think you can just edit the appropriate file in your .git directory (.git/refs/remotes/cvs/master in this case) and put the appropriate commit I'd in the file. I'm not sure if this will fix the problem in your other question though...

git-cvsimport远程分支有点伪造,所以我认为你可以只编辑.git目录中的相应文件(在这种情况下为.git / refs / remotes / cvs / master)并将相应的提交放入文件。我不确定这是否可以解决你的另一个问题...

#2


Did you try this: create a local branch that targets that remote branch, reset or rebase this local branch to your needs, push the local branch with -f option (force)?

您是否尝试过这样做:创建一个针对该远程分支的本地分支,根据您的需要重置或重新定位此本地分支,使用-f选项(强制)推送本地分支?