推送提交到另一个分支

本文翻译自:Push commits to another branch

Is it possible to commit and push changes from one branch to another. 是否可以将更改从一个分支提交到另一个分支。

Assume I commited changes in BRANCH1 and want to push them to BRANCH2 . 假设我在BRANCH1中提交了更改,并希望将其推送到BRANCH2中

From BRANCH1 , is it valid to do: BRANCH1执行以下操作是否有效:

git push origin **BRANCH2**

And then reset BRANCH1? 然后重置BRANCH1?


#1楼

参考:https://stackoom.com/question/wJQj/推送提交到另一个分支


#2楼

Certainly, though it will only work if it's a fast forward of BRANCH2 or if you force it. 当然,尽管仅当它是BRANCH2的快进或您强制使用时才起作用。 The correct syntax to do such a thing is 做这种事情的正确语法是

git push <remote> <source branch>:<dest branch> 

See the description of a "refspec" on the git push man page for more detail on how it works. 有关其工作原理的更多详细信息,请参见git push手册页上“ refspec”的描述。 Also note that both a force push and a reset are operations that "rewrite history", and shouldn't be attempted by the faint of heart unless you're absolutely sure you know

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值