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

Git Primer

Git Primer

A primer on using Git with comparisons made to SVN. Also slides on an effective Git Workflow (by nvie)

Avatar for Keith Mascarenhas

Keith Mascarenhas

October 03, 2012
Tweet

Other Decks in Technology

Transcript

  1. whygitisbetterthanx? awesome branching! the staging area it's local! fast, small,

    distributed... http://thkoch2001.github.com/whygitisbetter/ http://whygitisbetterthanx.com
  2. local staging.. Make changes to app.. git status OR git

    diff git add . git commit -m 'made xyz change'
  3. useful git add shortcuts.. git add . [stages modified and

    deleted, without new] git add -u [stages new and modified, without deleted] git add -A [stages All]
  4. branching! ^^ git branch <new_branch_name> [creates branch] git checkout <branch_name>

    [switch current working directory to this branch] 'master' is our default root branch.
  5. branching! ^^ git checkout master + git branch issue53 +

    git checkout issue53 = git checkout -b issue53 master git checkout -b [new branch name] [source branch name]
  6. [svn commit] Make changes in xyz.. git commit -am "changed

    xyz" git push <-> [svn commit] git push origin master git push [remote_name] [branchname_you_want_to_commit]
  7. [svn update] git fetch + git merge origin/master = git

    pull git pull origin/master <-> [svn update] git pull origin [branch_name]
  8. push a branch to remote! git checkout -b issue53 branch_x

    git commit git push origin issue53 Someone else.. git fetch
  9. tagging.. git tag -a v1.0 git tag [list them] git

    tag -l 'v1.4.2.*' v1.4.2.1 v1.4.2.2 v1.4.2.3 v1.4.2.4 git show v1.0 git push origin --tags
  10. misc.. git log [--oneline] [--graph] [--all] [--stat] git config --global

    alias.lolz "log --oneline --graph - all" git lolz --decorate git config --global alias.co "checkout" git log issue53 ^master [incoming: origin/master ^master] git log issue52 ^issue53 [outgoing: master ^origin/master]
  11. feature branches Creating a feature branch When starting work on

    a new feature, branch off from the develop branch. $ git checkout -b myfeature develop Switched to a new branch "myfeature" Incorporating a finished feature on develop Finished features may be merged into the develop branch definitely add them to the upcoming release: $ git checkout develop Switched to branch 'develop' $ git merge --no-ff myfeature Updating ea1b82a..05e9557 (Summary of changes) $ git branch -d myfeature Deleted branch myfeature (was 05e9557). $ git push origin develop feature: branch off develop merge back into develop name: anything except: master, develop, hotfix-*, release-*
  12. release: branch off develop merge back into develop & master

    name: release-* hotfix: branch off master merge back into develop & master name: hotfix-* (app-prod) (app-stg) (app-dev) app85 app85.0.1 app87
  13. you dont need to rtfd but it helps.. gitref.org git-scm.com/docs

    Introduction to Git - Scott Chacon bit.ly/introtogit bit.ly/introtogitdeck Branching Model bit.ly/branchingmodel This awesome deck! http://bit.ly/thisdeck