Skip to content

Instantly share code, notes, and snippets.

@teohm
Last active December 16, 2015 15:39
Show Gist options
  • Save teohm/5457023 to your computer and use it in GitHub Desktop.
Save teohm/5457023 to your computer and use it in GitHub Desktop.
git notes

Git for Busy Dev Team

Install Git

  • Mac OSX
  • Linux
  • Windows

Setup Git

  • identity (name, email)
  • SSH keys

Commands & Concepts

  • Basic
    • init, add, commit
    • 3 stages - working, staging, repo
  • Repo
    • .git
    • git object models
    • git graph
    • gitk, git log --graph --pretty=oneline
  • Shared repo
    • setup GitHub repo
    • clone, fetch, merge (fast-forward), push, tracking branch
  • Resolve merge conflict
    • team member B push conflicting changes, push failed, fetch, resolve conflict
  • Work on new feature / bug fix
    • create local branch, rebase master often (resolve conflict often), push remote, merge master
    • checkout, branch, rebase, rebase -i, push, merge (--ff-only / --no-ff)
    • stash, stash pop (when is working directory unsafe?)
  • Tag a release build
    • light-weight tagging
    • tagging with comment
    • git describe --always > BUILD_VERSION (when create build)
  • Undo mistakes
    • don't panic, local commit graph stores all your commits
    • gitk --all (show orphans?)
    • commit --amend
    • revert a commit or a range of commits
    • reset (3 stages)
    • reflog
    • cherrypick (commit on wrong branch)
    • git show REVISION:path/to/file.png > tmp.png (retrieve a file from specific revision in git repo)
  • Better CLI
    • git aliases (gist of ~/.git/config)
    • bash aliases (gist of ~/.bash_aliases)
    • bash prompt (link)
  • Design simple workflow for multi-stage env
    • 2 env: production, staging
    • concepts
      • branches: dev, master
      • hot feature, hot fix (merge --no-ff to both dev,master)
      • feature branch (merge to master only)
      • bug fix (merge to master only)
  • Bonus
    • Recommended video tutorials / materials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment