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

Git and Github: Tips and tricks

Wendy Liu
November 26, 2013

Git and Github: Tips and tricks

Presentation for HackMcGill. Intro to Git/Github plus various tips and tricks, all in one.

Wendy Liu

November 26, 2013
Tweet

More Decks by Wendy Liu

Other Decks in Programming

Transcript

  1. about me - Wendy Liu - 4th year Math &

    CS - 3 years experience with Git - 137-day Github commit streak - dellsystem on Twitter, Github, IRC
  2. keeps track of changes extremely flexible developed by linus torvalds

    completely free to use (and open source!) enter git.
  3. keeps track of changes extremely flexible developed by linus torvalds

    completely free to use (and open source!) primarily command-line enter git.
  4. website collaborative coding, via git (mostly) free to use major

    part of developer ecosystem (esp. OSS) what is github?
  5. what git can do for you versioning easy collaboration blame

    tracking down bugs safe experimentation statistics
  6. what github can do for you issue-tracking even easier collaboration

    remote backups access your files from anywhere graphical, easy-to-use UI
  7. git commit -m 'test' CHANGES I WANT IN MY NEXT

    COMMIT ALL THE OTHER CHANGES a new commit, with message 'test'
  8. CHANGES I WANT IN MY NEXT COMMIT ALL THE OTHER

    CHANGES the commit with message 'test' (nothing here yet)
  9. multiple remotes git remote add origin [url] git remote add

    upstream [different URL] useful when pulling from other developers
  10. good commit messages Fix bug (50 chars max, capitalised, imperative)

    Longer description explaining what the commit does. Wrap at 72 characters. Don't forget the blank line. bit.ly/gitcommit
  11. aliases git s = git status git add = git

    add --patch git ds = git diff --staged git amend = git commit --amend git say = git commit -m git un = reset --soft HEAD^1
  12. fixing merge conflicts 1. Don't panic 2. git status 3.

    Look for the <<< 4. Stage & commit
  13. moving files git mv [source] [destination] instead of: mv [source]

    [destination] git rm [source] git add [destination]
  14. pushing to remotes git push origin master git push origin

    localbranch:remotebranch git push origin :remotebranch (deletes it)
  15. stashing edits git stash git stash apply git stash pop

    (applies, then removes from stack)
  16. issues in commits "Fix #54" -> closes issue #54 from

    the commit "For #54" -> links to #54 from commit, & vice versa
  17. all from your browser edit, commit, send a pull request

    ... all without leaving your browser