Change root of a branch in git

前端 未结 4 1406
予麋鹿
予麋鹿 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:24

    git rebase should, like you say, allow you to change the base of deploy:

    git checkout deploy
    git rebase v1.1 # using the tag
    (or:
     git rebase J # SHA1 of J
     or
     git rebase master~1
    )
    

    But you will end up with

    C'---D'---E' deploy
    

    That is, the SHA1 of the commits part of deploy branch are rewritten, which isn't too bad if nobody cloned said deploy branch and was working on it.
    Since it is a branch for deployment, that is most likely the case (i.e. nobody was working on a clone of said branch).

提交回复
热议问题