Get the difference between two branches in Git

后端 未结 3 1510
無奈伤痛
無奈伤痛 2020-12-22 23:23

I did following (I simplified this comparing to a reality):

  • created a branch Branch1, switched to it
  • added file File1
3条回答
  •  一个人的身影
    2020-12-23 00:08

    Let's assume that you started on the branch master. Then you can do:

    git diff master Branch1 > ../patchfile
    git checkout Branch2    
    git apply ../patchfile
    

    Alternatively, if your goal is to rewrite history, then you could use an interactive rebase to squash commits.

提交回复
热议问题