Change root of a branch in git

前端 未结 4 1408
予麋鹿
予麋鹿 2021-02-05 11:41

I\'m using git and want to change the base of an exiting branch. This is caused by a deployment system, which pulls this explicit branch into my production environment. When pla

4条回答
  •  灰色年华
    2021-02-05 12:14

    I don't understand why you'd want to lose your original branch. What I would do in such a case:

     # create a new branch from your 1.1 tag
     git checkout -b deploy1.1 v1.1 
     # merge your existing branch into this one
     git merge deploy
    

    EDIT: added schema

    You'll end up with something like that

           C---D---E deploy
           /        \_______ 
          /                  F deploy1.1
         /                  /
    A---B---F---G--H--I--J--K--L
         \                   \
        v1.0                 V1.1
    

提交回复
热议问题