Reset other branch to current without a checkout

后端 未结 3 690
天涯浪人
天涯浪人 2020-12-04 07:27

I\'m writing some scripts for my Git workflow.

I need to reset other (existing) branch to the current one, without checkout.

Before:

 Current         


        
3条回答
  •  没有蜡笔的小新
    2020-12-04 08:07

    The workflows you describe are not equivalent: when you perform reset --hard you lose all the changes in the working tree (you might want to make it reset --soft).

    What you need is

    git update-ref refs/heads/OtherBranch refs/heads/CurrentBranch
    

提交回复
热议问题