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

A Bit More Git

Ben Woodall
February 13, 2013

A Bit More Git

Ben Woodall

February 13, 2013
Tweet

More Decks by Ben Woodall

Other Decks in Technology

Transcript

  1. Faye:Git_Plus_Plus$ git init Initialized empty Git repository in /Users/benwoodall/Dropbox/Talks/ Git_Plus_Plus/.git/

    Faye:Git_Plus_Plus[master]$ git add . Faye:Git_Plus_Plus[master]$ git commit -am 'initial commit!' [master (root-commit) c2a78ae] initial commit! 10 files changed, 240 insertions(+) create mode 100644 Git-Icon-1788C.png create mode 100644 Git-Logo-1788C.png create mode 100644 always_be_commiting.jpg create mode 100644 always_be_commiting.pxm create mode 100644 always_be_commiting_fixed.png create mode 100644 freeze_jump.jpg create mode 100644 git-argh.png create mode 100644 notes.txt create mode 100644 ruby-language.png create mode 100644 talk.txt Faye:Git_Plus_Plus[master]$ :)
  2. Faye:Git_Plus_Plus[master]$ git status index.html: needs merge # On branch master

    # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # unmerged: index.html # <<<<<<< HEAD:index.html <div id="footer">contact : [email protected]</div> ======= <div id="footer"> please contact us at [email protected] </div> >>>>>>> iss53:index.html
  3. Faye:Git_Plus_Plus[master]$ git status index.html: needs merge # On branch master

    # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # unmerged: index.html # <<<<<<< HEAD:index.html <div id="footer">contact : [email protected]</div> ======= <div id="footer"> please contact us at [email protected] </div> >>>>>>> iss53:index.html Faye:Git_Plus_Plus[master]$ git push origin master fatal: remote error: You can't push to git:// github.com:benwoody/demo_git.git Use [email protected]:benwoody/demo_git.git
  4. Faye:Git_Plus_Plus[add_login]$ git status # On branch master # Untracked files:

    # (use "git add <file>..." to include in what will be committed) # # curly.png # kanban_board.jpg nothing added to commit but untracked files present (use "git add" to track) Faye:Git_Plus_Plus[add_login]$ git add . Faye:Git_Plus_Plus[add_login]$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: curly.png # new file: kanban_board.jpg # Faye:Git_Plus_Plus[add_login]$ git commit ?
  5. Faye:rails[master]$ git lg * 3726080 - (HEAD, origin/master, origin/HEAD, master)

    Merge pull request #6832 from frodsan/nodoc_patch1 (8 months ago) <Rafael Mendonça> |\ | * bc7ac33 - add :nodoc: to internal implementations [ci skip] (8 months ago) <Francesco Rodriguez> |/ * 96ce1f2 - Merge pull request #6821 from tonywok/pg_datetime_precision (8 months ago) <Rafael Mendonça França> |\ | * 6657ec9 - Allow precision option for postgresql datetimes (8 months ago) <Tony Schneider> |/ * a232831 - Merge pull request #6829 from frodsan/misunderstood_param (8 months ago) <Rafael Mendonça França> |\ | * 629bc03 - change param name to improve documentation (8 months ago) <Francesco Rodriguez> |/ * 35ee8fa - Merge branch 'master' of github.com:lifo/docrails (8 months ago) <Vijay Dev> |\ | * 6285675 - fixes a few mistakes in api docs [ci skip] (8 months ago) <Vijay Dev> | * 741cb5b - copy edit the assets guide[ci skip] (8 months ago) <Vijay Dev> | * d569bfe - update ActiveModel::Callbacks documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * c3025e8 - add description to ActiveModel::MissingAttributeError [ci skip] (8 months ago) <Francesco Rodriguez> | * 95a938a - add example to ActiveModel::AttributeMethods#undefine_attribute_methods [ci skip] (8 months ago) <Francesco Rodriguez> | * f975c4b - add docs to AM::AttributeMethods#define_attribute_method [ci skip] (8 months ago) <Francesco Rodriguez> | * b5b350a - fix ActiveModel::AttributeMethods#alias_attribute documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * bf3332b - update ActiveModel::AttributeMethods documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * 8421361 - Small typo in Backporting instructions. (8 months ago) <Godfrey Chan> Faye:rails[master]$ git commit -m add example to ActiveModel::AttributeMethods#undefine_attribute_methods
  6. Faye:rails[master]$ git lg * 3726080 - (HEAD, origin/master, origin/HEAD, master)

    Merge pull request #6832 from frodsan/nodoc_patch1 (8 months ago) <Rafael Mendonça> |\ | * bc7ac33 - add :nodoc: to internal implementations [ci skip] (8 months ago) <Francesco Rodriguez> |/ * 96ce1f2 - Merge pull request #6821 from tonywok/pg_datetime_precision (8 months ago) <Rafael Mendonça França> |\ | * 6657ec9 - Allow precision option for postgresql datetimes (8 months ago) <Tony Schneider> |/ * a232831 - Merge pull request #6829 from frodsan/misunderstood_param (8 months ago) <Rafael Mendonça França> |\ | * 629bc03 - change param name to improve documentation (8 months ago) <Francesco Rodriguez> |/ * 35ee8fa - Merge branch 'master' of github.com:lifo/docrails (8 months ago) <Vijay Dev> |\ | * 6285675 - fixes a few mistakes in api docs [ci skip] (8 months ago) <Vijay Dev> | * 741cb5b - copy edit the assets guide[ci skip] (8 months ago) <Vijay Dev> | * d569bfe - update ActiveModel::Callbacks documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * c3025e8 - add description to ActiveModel::MissingAttributeError [ci skip] (8 months ago) <Francesco Rodriguez> | * 95a938a - add example to ActiveModel::AttributeMethods#undefine_attribute_methods [ci skip] (8 months ago) <Francesco Rodriguez> | * f975c4b - add docs to AM::AttributeMethods#define_attribute_method [ci skip] (8 months ago) <Francesco Rodriguez> | * b5b350a - fix ActiveModel::AttributeMethods#alias_attribute documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * bf3332b - update ActiveModel::AttributeMethods documentation [ci skip] (8 months ago) <Francesco Rodriguez> | * 8421361 - Small typo in Backporting instructions. (8 months ago) <Godfrey Chan> Faye:rails[master]$ git commit -m add example to ActiveModel::AttributeMethods#undefine_attribute_methods Faye:rails[master]$ git commit -m add example to ActiveModel::AttributeMethods#undefine_attribute_methods Faye:rails[master]$ git checkout 6285675 Note: checking out '6285675'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 6285675... fixes a few mistakes in api docs [ci skip] Faye:rails[]$ git checkout -b making_fixes Switched to a new branch 'making_fixes' Faye:rails[making_fixes]$ git diff 6285675
  7. Faye:demo_repo[fixed_headers]$ git push ! [rejected] master -> master (non-fast forward)

    error: failed to push some refs to '[email protected]:benwoody/demo_repo.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'non-fast forward' Faye:demo_repo[fixed_headers]$ git wtf?!?!!!11!!1
  8. Faye:demo_repo[fixed_headers]$ git push ! [rejected] master -> master (non-fast forward)

    error: failed to push some refs to '[email protected]:benwoody/demo_repo.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'non-fast forward' Faye:demo_repo[fixed_headers]$ git wtf?!?!!!11!!1 Faye:demo_repo[fixed_headers]$ git fetch remote: Counting objects: 52, done. remote: Compressing objects: 100% (18/18), done. remote: Total 51 (delta 30), reused 50 (delta 29) Unpacking objects: 100% (51/51), done. From github.com:benwoody/demo_repo c2a78ae..2e472ae master -> origin/master Faye:demo_repo[fixed_headers]$ git checkout master Switched to branch 'master' Faye:demo_repo[master]$ git rebase origin/master First, rewinding head to replay your work on top of it... Applying: hey now! Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Applying: added images Faye:demo_repo[master]$ git checkout fixed_headers Switched to branch 'fixed_headers' Faye:demo_repo[fixed_headers]$ git rebase master First, rewinding head to replay your work on top of it... Applying: added staged command
  9. Faye:test[fixed_headers]$ git rebase -i master Faye:test[fixed_headers]$ git rebase -i HEAD~n

    - [e]dit to mark a commit for amending. - [r]eword to change the log message. - [s]quash to merge a commit with the previous one. - [p]ick to include this commit into history - [f]ixup to merge a commit with the previous one and discard the log message.
  10. pick 73c97d6 tests still failing s 17f8cb3 iterating through array

    for tests s 355749c fixed some typos in tests s c963ba4 tests passing. working on signin reset method s dc2d50c red. green. refactor! s 71d5e53 bad call to block s 8811459 now using block_given? s eda3a0c one more test to go s 26ab78d cleaning up more typos before the push to github s 316e6b7 Headers fixed. Cleans up issue 22 # Rebase 7aedc06..316e6b7 onto 7aedc06 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. #
  11. • Never work in master • Make feature/issue branches •

    Always Be Committing • git fetch for upstream changes • git rebase to change history • ? • Profit!
  12. Zach Holmans 'how github uses github to build github' zachholman.com/talk/how-github-uses-github-to-build-github/

    Try Git try.github.com/levels/1/challenges/1 Codeschool’s ‘Git Real’ www.codeschool.com/courses/git-real Git Terminal benwoodall.com/blog/2012/12/04/git-terminal-colors/ Git Aliases gist.github.com/benwoody/4736048