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

Understanding Git and a Standard Workflow

Understanding Git and a Standard Workflow

This is a talk I gave at LiveRail as an initiation to Git and the standard Git workflow.

Avatar for Travis Vocino

Travis Vocino

May 01, 2014
Tweet

Other Decks in Programming

Transcript

  1. • Local vs. Remote • Stage, Commit, Push • Stashing

    • Branching • Merging Workflow
  2. Local clone gives you a local copy of a repository

    Remote Branches Commits Tags Local Branches Commits Tags $ git clone git://git.liverail.com/admanager-sdk
  3. Local vs. Remote clone gives you a local copy of

    a repository Remote Branches Commits Tags Local Branches Commits Tags $ git clone git://git.liverail.com/admanager-sdk nearly every operation is now working off of local data — insanely fast your workflow does not have a single point of failure — distributed insanely awesome incredible workflows — awesome
  4. Local commits, branches, and tags can all exist locally and/or

    remotely Local Remote master ✔ ✔ feature/create_dashboard ✔ ✔ feature/add_menu_item_x ✔ feature/change_header_color ✔ $ git checkout feature/create_dashboard
  5. Local you can name remotes and have more than one

    .git/config Name Description origin The default (where you cloned from) upstream Often used if you need to track commits from outside of your team.
 A javascript library on Github is needed but LiveRail must make changes to it. 
 The source Github repo would be the upstream and LiveRail’s hosted repo would be origin. staging Used to sync with a staging or QA server.
  6. Local $ git pull upstream dev git push pull origin

    staging prod master dev feature/new_css feature/update_class prod $ action remotes branches
  7. Local working with remotes like a boss $ git push

    prod master you can push things from local to a remote $ git fetch upstream you can fetch a remote $ git pull origin master you can pull changes from a remote to local pull is fetch+merge
  8. Stage, Commit, Push staging a file is putting it on

    deck to commit Commit styles.css index.html Push styles.css index.html Stage styles.css index.html
  9. Stage, Commit, Push staging a file is putting it on

    deck to commit Stage styles.css Commit styles.css index.html Push styles.css index.html index.html
  10. Stage, Commit, Push committing a file is putting it on

    deck to push Stage styles.css index.html Commit styles.css index.html Push styles.css index.html
  11. Stage, Commit, Push committing a file is putting it on

    deck to push Stage styles.css index.html Commit styles.css index.html Push styles.css index.html app.js framework.js app.js framework.js app.js framework.js
  12. Branching A B B Always Be Branching BRANCHING local branches

    give you the freedom to experiment they let you separate and organize different directions they can have special and meaningful names to you
  13. Branching branching like a boss $ git checkout my-awesome-branch checkout

    an existing local or remote branch $ git checkout -b my-new-branch create a new branch with the same command $ git branch -d my-unused-branch kill branches you don’t care about
  14. Stashing stashing is like a temporary commit Branch A style.css

    index.html app.js $ git stash Stash style.css index.html app.js Branch Y style.css index.html app.js
  15. Stashing stashing is like a temporary commit Branch A style.css

    index.html app.js $ git stash Stash style.css index.html app.js Branch Y style.css index.html app.js stashing grabs the dirty state of your working directory your stash is saved in a stack that can be reapplied helpful before a merge or to quickly address a bug fix
  16. Merging merging brings one branch’s changes into your branch Your

    Branch style.css index.html app.js $ git merge your-branch My Branch style.css index.html app.js always that into this
  17. Merging Your Branch style.css index.html app.js My Branch style.css index.html

    app.js My Branch* style.css index.html app.js CONFLICT merging brings one branch’s changes into your branch always that into this $ git merge your-branch
  18. Merging resolving merge conflicts in plain text 1 stuff we

    both agree on 2 stuff we both agree on <<<<<<< my-branch-name 3 stuff I have 4 stuff I have ======= 3 stuff you have 4 stuff you have >>>>>>> your-branch-name 5 stuff we both agree on 6 stuff we both agree on
  19. Merging resolving merge conflicts in plain text 1 stuff we

    both agree on 2 stuff we both agree on <<<<<<< my-branch-name 3 stuff I have 4 stuff I have ======= 3 stuff you have 4 stuff you have >>>>>>> your-branch-name 5 stuff we both agree on 6 stuff we both agree on
  20. Merging resolving merge conflicts in plain text 1 stuff we

    both agree on 2 stuff we both agree on <<<<<<< my-branch-name 3 stuff I have 4 stuff I have ======= 3 stuff you have 4 stuff you have >>>>>>> your-branch-name 5 stuff we both agree on 6 stuff we both agree on
  21. Merging resolving merge conflicts in plain text 1 stuff we

    both agree on 2 stuff we both agree on <<<<<<< my-branch-name 3 stuff I have 4 stuff I have ======= 3 stuff you have 4 stuff you have 5 stuff we both agree on 6 stuff we both agree on >>>>>>> your-branch-name
  22. Merging resolving merge conflicts in plain text 1 stuff we

    both agree on 2 stuff we both agree on 5 stuff we both agree on 6 stuff we both agree on 3 stuff you have 4 stuff you have