gpt4 book ai didi

git - 在推送到远程之前重新设置本地 Git 分支

转载 作者:太空狗 更新时间:2023-10-29 13:11:06 26 4
gpt4 key购买 nike

Remote :来源

$ git branch
* master

$ git checkout -b "new_feature"

现在我在“new_feature”分支上做了几次提交,并希望在更新后将其推送到 origin

$ git branch
master
* new _feature

$ git pull --rebase origin new_feature
$ git push origin new_feature

这是在推送到远程之前更新本地分支的正确方法吗?

最佳答案

你想用

git pull --rebase origin master

arguments to git pull必须是一个可选的 Remote ,以及一个可选的 refspec 或引用/分支 在该 Remote 上:

git pull [options] [<repository> [<refspec>…]]

new_feature 将不起作用,因为它是一个本地分支,此外,它对 rebase 没有意义,因为您想将修订传递给 rebase 分支 new_feature 之上。如果您检查了 new_feature,则可以理解/暗示这是您要rebase 的分支,这就是rebase 通常的工作方式。

关于git - 在推送到远程之前重新设置本地 Git 分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18604025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com