Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Version Control Tips & Tricks

Version Control Tips & Tricks

Nervous of version control? Don’t panic! you’re not on your own. I've put together a run down of some of my tricks and ‘good citizen’ techniques to avoid the worst kinds of conflicts and deal with the remaining ones as efficiently as possible. Branching policies, basic conflict resolution, proactive diffs can all ease the pain of a tricky integration.

Tess Barnes

October 14, 2015
Tweet

More Decks by Tess Barnes

Other Decks in Programming

Transcript

  1. Version Control
    Tips, tricks and good citizenship
    blog.tessbarnes.uk @crataegustess
    Tess Barnes :: October 2015

    View Slide

  2. We see a lot of
    this…
    so we have to
    get used to this…

    View Slide

  3. But these… lets be honest…

    View Slide

  4. Really, really honest…

    View Slide

  5. Why do we see so many?
    lots of developers
    lots of overlapping work
    context swapping
    impossible to talk all the time
    we are a bunch of (trainee) php scouts

    View Slide

  6. So how do we fix them?
    Photo credit (CC BY 2.0) JD Hancock

    https://www.flickr.com/photos/jdhancock/8755184025

    View Slide

  7. Practice bonsai
    cultivate a well shaped tree
    check out at the right level
    branch carefully
    clean up
    photo credit (CC BY-ND 2.0) Beverly Vealach 

    https://www.flickr.com/photos/cowtools/293244244

    View Slide

  8. Be prepared
    Know the tools
    Keep a clean working copy - regular cleanup
    Avoid switching - run multiple working copies
    Watch where you leap - check commit logs first
    Communicate, collaborate - be a good citizen

    View Slide

  9. Interleaving changes
    how it occurs:
    a file with an old method
    changed by dev a to new method
    changed by dev b to different new method
    dev a commits, dev b updates
    can’t add my block above their block as it would create
    interleaved lines

    View Slide

  10. Interleaving changes - fixing
    how to fix:
    copy file.ext.mine to a new location
    accept in diff by ‘use {their} whole file’ & save
    copy in additional new method from .mine file

    View Slide

  11. Tree conflicts
    • Watch where you leap!
    • announce big refactors
    • check what others have 

    committed in this area
    • collaborate to get early warning
    • _then_ consider merging

    View Slide

  12. Tree conflict - add
    If you’re the second one in:
    1. undo the add
    2. move your file somewhere outside working copy
    3. merge up to your branch / working copy & commit
    4. manually copy changes in

    View Slide

  13. Tree conflict - delete
    someone has deleted that nice file you fixed so
    beautifully…
    so find them and talk - it could be just a rename!
    renames can sometimes be solved by patch file
    massive refactors? talk, collaborate, hand copy
    feature removal? don't get frustrated, get coffee

    View Slide

  14. Solve with tech (git)
    Switching context? 

    Stash your work in progress
    Separate coding standards changes? 

    Cherry pick your commits in ‘hunks’
    Tree conflicts when adding files?

    No such thing?
    Tree conflicts against deleted files?

    Just choose to delete or re-add

    View Slide

  15. photo credit (CC BY-SA 2.0) Sarabbit

    https://www.flickr.com/photos/sarabbit/4549185468

    View Slide

  16. Interesting reads
    http://phpboyscout.uk/php-scout/
    http://betterexplained.com/articles/a-visual-guide-to-version-control/
    http://www.makebetterthings.com/tag/subversion/
    http://tortoisesvn.net/docs/release/TortoiseSVN_en/index.html
    http://tortoisegit.org/docs/tortoisegit/
    https://git-scm.com/downloads
    http://www.laliluna.de/articles/2012/06/15/when-subversion-fails.html

    View Slide