Git merge squash repeatedly

后端 未结 5 2136
暗喜
暗喜 2020-12-04 09:23

I\'m trying to have two branches with binary files in git - one \"development\" and one \"stable\". The development branch can have several changes of these files before I w

5条回答
  •  青春惊慌失措
    2020-12-04 09:27

    Starting with

          X stable
         /                   
    a---b---c---d---e---f---g development
    

    You can use the following steps to copy the last commit from your development branch to your stable branch:

    git checkout development@{0}  # get working tree from "development", detach HEAD
    git reset --soft stable  # reposition detached HEAD on "stable"
    git commit  # enter the appropriate commit message
    git branch temp  # create a temporary branch "temp" at HEAD
    git checkout temp  # get on the new temporary branch
    git branch -M stable  # rename "temp" to "stable"
    

    so you end up with:

          X-------------------G stable
         /                   
    a---b---c---d---e---f---g development
    

    If you continue work on "development", e.g.,

          X-------------------G stable
         /                   
    a---b---c---d---e---f---g---h---i---j development
    

    you can repeat the same git commands as above and you will end up with:

          X-------------------G-----------J stable
         /                   
    a---b---c---d---e---f---g---h---i---j development
    

提交回复
热议问题