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

"git with it"

"git with it"

A few tips on using git. Atomic commits FTW!

Talk given at LeedsPHP meet-up on 18/10/17. (https://www.meetup.com/preview/leedsphp/events/243229198)

Tom de Bruin

October 18, 2017
Tweet

More Decks by Tom de Bruin

Other Decks in Programming

Transcript

  1. “git with it” A few tips on using git in

    teams Tom de Bruin | @deadlyhifi
  2. What’s the point of a VCS? • You don’t want

    to lose your code • You want a history of your work. • You want to have multiple people committing to the same code base. • You want to make it easy to deploy your code. • You want to easily experiment with ideas. • Any others?
  3. Atomic Commits “In the field of computer science an atomic

    commit is an operation that applies a set of distinct changes as a single operation…” https://en.wikipedia.org/wiki/Atomic_commit
  4. Make each feature a separate commit git commit -m “ticket-1

    - fix code style issues … git commit -m “ticket-1 - update config
  5. Rebasing git rebase master • Goes back to the point

    you branched off master and replay your commits • This happened • Then this happened • Then this happened git rebase -i HEAD~3 • If you need to amend a particular commit just go back to it and make the changes.
  6. Top tip # list git branches with their descriptions function

    gb() { branch="" branches=`git branch --list` while read -r branch; do clean_branch_name=${branch//\*\ /} description=`git config branch.$clean_branch_name.description` printf "%-15s %s\n" "$branch": "$description" done <<< "$branches" }