better commit than sorry
play

Better Commit than Sorry https://xkcd.com/1597/ What is and why - PowerPoint PPT Presentation

Better Commit than Sorry https://xkcd.com/1597/ What is and why should we use it? DVCS - distributed version control system allows lots of people to work together tracks file version in a shared history assists in the


  1. Better Commit than Sorry https://xkcd.com/1597/

  2. What is and why should we use it? DVCS - distributed version control system ● ● allows lots of people to work together tracks file version in a shared history ● ● assists in the development process https://i.stack.imgur.com/yof9f.png

  3. GIT ● config ● managing files The Basics behind the curtain ●

  4. git config (--global | --system) ● /etc/gitconfig | system wide ● ~/.gitconfig | user wide ● .git/config | project wide ● user.name “Florian Sattler” ● user.email “sattlerf@fim.uni-passau.de” ● alias.fancyLog “log --color --graph” git config --list

  5. file status https://git-scm.com/images/about/index1@2x.png

  6. file status git reset git add edit git add modified untracked unmodified staged git checkout git reset git rm --cached git commit git diff | changed and not staged git diff --staged | compares staged with last commit

  7. git commit blob: aa43aa {file content} blob: 2d5edf tree: 4bbc25 {file content} tree: 78ba8a blob: aa43aa blob: 2d5edf tree: 78ba8a blob: 30d77f blob: 30d77f commit: 149fbd {file content} tree: 4bbc25 parent: 8869e2 git cat-file -p {hash} author: Florian committer: Florian message: {new stuff}

  8. The history snapshot snapshot snapshot commit: 37a921 commit: 8869e2 commit: 149fbd tree: fe8e13 tree: deb987 tree: 4bbc25 parent: 151c57 parent: 37a921 parent: 8869e2 author: Mr Bug author: Mr Fix author: Florian committer: Mr Crless committer: Mr Fix committer: Florian commit: 149fbd message: {la di da} message: {fixed foo} message: {new stuff} tree: 4bbc25 parent: 8869e2 author: Florian committer: Florian message: {new stuff}

  9. Many commits, ● braches ● remote interaction know handle it!!! merging ● rebase ●

  10. Branches HEAD current branch master branch pointer commit: 37a921 commit: 8869e2 commit: 149fbd testing commit: 809d82 HEAD testing git branch testing | create branch named testing HEAD git checkout testing | switch HEAD to testing

  11. Merging HEAD HEAD master master commit: 37a921 commit: 8869e2 commit: 149fbd commit: 877f43 commit: 809d82 testing

  12. Merging HEAD HEAD master master commit: 8869e2 commit: 149fbd commit: 877f43 commit: 8390ab merge commit: 809d82 commit testing git merge testing | merge branch testing into master

  13. remote interaction ● git remote -v | show URLs ○ add [r-name] [url] | add new remote ○ ○ show [r-name] | shows infos of remote ○ rm [r-name] | remove remote rename [r-old] [r-new] | local rename name of the remote ○ git fetch [r-name] | gets objects/refs from remote ● ● git pull | gets o/r from remote and merges them into own ● git push [r-name] [branch] | pushes local o/r to remote origin ssh://gitblit/~vulder/foo.git (fetch) origin ssh://gitblit/~vulder/foo.git (push) github git@github.com:vulder/foo.git (fetch) github git@github.com:vulder/foo.git (push)

  14. remote branches origin/master master origin/master commit: 8869e2 commit: 149fbd commit: 877f43 origin/testing testing commit: 809d82 HEAD origin/testing testing git push | push current branch to remote HEAD

  15. merge conflict HEAD HEAD master master origin/master master commit: 8869e2 commit: 149fbd commit: 877f43 commit: 8390ab merge commit: 809d82 commit origin/testing testing git pull | get changes from origin git checkout master | switch to brache master HEAD git merge testing | merge testing into master

  16. http://www.columbia.edu/~zjn2101/intermediate-git/meme-merge.jpg

  17. resolving conflicts (git merge testing) git mergetool -t diffuse master testing git commit

  18. 3-way merge HEAD master BASE LOCAL commit: 8869e2 commit: 149fbd commit: 877f43 commit: 8390ab commit: 809d82 REMOTE git config merge.conflictStyle diff3 testing

  19. when git turns into guitar hero https://i.kinja-img.com/gawker-media/image/upload/hvkhczj1c4qqn5edap0e.jpg https://pbs.twimg.com/media/CaI8xA3W0AA6wMe.png

  20. rebase master c1 c2 c2 c3 c5 c6 c8 c4 c7 c9 c4 c7 c9 testing testing git rebase master

  21. rebase II master feature c1 c2 c2 c3 c5 c6 c8 c10 c11 c4 c7 c9 testing c10 c11 feature git rebase --onto master testing feature

  22. rebase III master c1 c2 c2 c3 c5 c6 c8 c4 c7 c7 c9 c9 c10 c11 testing git rebase --onto testing~4 testing~2 testing

  23. rebase III master c1 c2 c2 c3 c5 c6 c8 c4 c7 c7 c9 c9 c10 c11 testing git rebase --onto testing~4 testing~2 testing

  24. rebase III master c1 c2 c2 c3 c5 c6 c8 c4 c10’ c12 c11’ c13 testing git rebase --onto testing~4 testing~2 testing

  25. rebase interactive master git rebase -i master~3

  26. https://imgur.com/XFQLB https://imgur.com/c4jt321

  27. rebase problem master c1 c2 c2 c3 c5 c6 c8 c4 c10 c12 c13 c11 testing cXX cXY remote dev git config pull.rebase true

  28. git reflog logs the states where branches/HEAD was before a change occurred git reset --hard c38d994 repo state before “reset --hard HEAD~”

  29. Let’s work with ● tags ● workflows others finding bugs ● more useful commands ●

  30. tags (git tag) lightweight tag: git tag [new tag name] annotated tag: git tag -a [tag] -m [message] + sign tag with -s default email key Conf: user.signingKey = [keyid] git push [remote] [tag-name]

  31. github - GPG support

  32. git request-pull git request-pull <start> <url> [<end>] git request-pull origin/master git@github.com:vulder/foo.git

  33. centralized workflow central repository server/github John Eve Smith

  34. integration-manager workflow blessed repository John public repo Eve public repo Smith John Eve integration manager

  35. dictator and lieutenants workflow blessed repository Smith dictator Lieutenant I Lieutenant II John public repo Eve public repo

  36. git flow (https://github.com/nvie/gitflow) ● master ● develop feature ● release ● ● hotfix nvie.com

  37. git bisect HEAD master c1 c2 c2 c3 c4 c5 c6 c7 c8 c9 good good bad bad bad

  38. git blame {file} tool: tig

  39. git cherry-pick apply changes from existing commit c1 c2 c2 c3 c5 c6 c6 c8 c4 c7 c6’ c9 git cherry-pick c6 -n | no commit ● ● -e | edit ● -x | add from line

  40. git revert reverte existing commit c1 c2 c2 c3 c5 c6 c6 c8 c4 c7 c6’ c9 c10 -c7 git revert c7 -n | no commit ● git revert -n master~5..master~2 ● -e | edit

  41. hooks (.git/hooks) ● pre-commit | invoked by git commit ● commit-msg | invoked by git commit pre-push | invoked by git push ● pre-receive/update | invoked by git-receive-pack ●

  42. Tools, Tools, ● big files ● tig Tools git GUI ● handling .docx ●

  43. tooling ● gitk tig ● ● sourcetree git-cola ●

  44. tooling gitattributes ● gitk .git/info/attributes | path/file spec settings tig ● *.docx diff=word | word filter ● sourcetree 1. #!/bin/bash | script to call docx converter git-cola ● 2. docx2txt.pl $1 - ● docx to text git config diff.word.textconv docx2txt infos @ https://git-scm.com/book/uz/v2/Customizing-Git-Git-Attributes @ http://docx2txt.sourceforge.net/

  45. other stuff ● git clean ● git grep read-tree + subtree ● git replace ● ● git fsck ● git bundle git log -L ● git describe ● ● git archive ● git rerere git submodules ● ...

Recommend


More recommend