如何强制分支更新?

时间:2019-12-22 03:30:28

标签: git github

这是有关git branch和git pull的问题。

当前情况如下。

  1. 已在远程存储库中创建了一个“发布”分支。 (远程)

  2. 在本地拉“发布”分支。 (本地)

  3. 从远程存储库中删除了“发布”分支。 本地仍然有一个“发布”分支。 (远程)

  4. 已在远程存储库中创建了具有新功能的“发布”分支。 (远程)

  5. 我希望使用远程存储库中的新“ release”分支来更新本地“ release”分支。 (本地)

git pull不起作用,因为分支名称相同,但是分支创建方式不同。

有什么好方法吗?

请给我一些建议。

4 个答案:

答案 0 :(得分:0)

如果您删除本地分支,然后再次创建它,它将为您完成。示例:

TextInputLayout

答案 1 :(得分:0)

只需将远程发行分支提取到本地发行分支即可。
git checkout master
git fetch <your-remote-repo> <your-remote-release-branch>:<your-local-release-branch>
git checkout <your-local-release-branch>

答案 2 :(得分:0)

可以通过两个步骤完成:

git fetch the-remote # fetch information about the position of branches/tags on the remote
git branch -f release the-remote/release # set the position of local release to whatever point the-remote/release is at... no merging/rebasing involved

答案 3 :(得分:0)

好吧,如果您没有要保留的本地更改,则只需重设

git reset --hard origin/releaseBranch