$30 off During Our Annual Pro Sale. View Details »

Reverting a merge. Without console. Mikhail Matrosov, Align Technology, CEE-SECR 2017

CEE-SECR
October 21, 2017

Reverting a merge. Without console. Mikhail Matrosov, Align Technology, CEE-SECR 2017

If you are a little frustrated with what “reverting a merge” is, this talk is for you. Using this operation as an example, I will talk about some important yet non-obvious Git concepts, which we need in our daily work. Notably, I am not going to show a single console command, rather using client with graphical interface to perform all operations. The basic knowledge of Git is assumed.

CEE-SECR

October 21, 2017
Tweet

More Decks by CEE-SECR

Other Decks in Technology

Transcript

  1. October 2017, St. Petersburg Software Engineering Conference Russia Reverting a

    merge Mikhail Matrosov Technical Manager at Align Technology
  2. 2

  3. 3

  4. 4 

  5. 5  ^

  6. 6  ^ !..

  7. 7  ^ ?..

  8. Header Hash Changeset 8 master Parents 1 – regular >1

    – merge 0 – root
  9. A B C D E M master dev 9

  10. A B C D E M master 10 1 2

    1 = merged to 2 = merged from
  11. A B C D E M’ master dev 11 2

    1
  12. 12 A B C D E M master 1 2

    A B C D E M’ master 2 1
  13. 13

  14. 14

  15. A B C D E master 15 M ^M F

    M2 dev only F is merged
  16. A B C D E master 16 M ^M F

    ^^M dev F is merged, D and E brought back by ^^M M2 Pros: commits D and E are preserved Cons: complicated history
  17. A B C D E master 17 M ^M dev

    D’ E’ F M2 Pros: new branch has regular workflow Cons: commits D and E are duplicated
  18. A B C D E master 18 M ^M dev

    ^^M F M2 Pros: preserves conflicts resolution happened in M Cons: commits D and E are not visible in new branch
  19. 19

  20. A B C D E M master dev 20

  21. Resetting the merge • When you immediately realize the problem

    • --force-with-lease 21
  22. 22

  23. 23

  24. References • Basic info: https://git- scm.com/blog/2010/03/02/undoing-merges.html • More details: https://opensource.apple.com/source/Git/Git-

    26/src/git-htmldocs/howto/revert-a-faulty- merge.txt • On order of commits: http://devblog.nestoria.com/post/98892582763/ maintaining-a-consistent-linear-history-for-git 24