Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Git tricks

6.729 Aufrufe

Veröffentlicht am

  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • git
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Git tricks

  1. 1. Git Tricks Arthur Zapparoli @arthurgeek
  2. 2. Tópicos
  3. 3. Ambiente
  4. 4. Ambiente Configurações
  5. 5. Ambiente Configurações Comandos
  6. 6. Ambiente Configurações Comandos Features
  7. 7. Ambiente
  8. 8. git-completion
  9. 9. git-completion# Copie o arquivo do source do Git~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh
  10. 10. git-completion# Copie o arquivo do source do Git~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh# Edite seu .bashrc~$ vim ~/.bashrc
  11. 11. git-completion# Copie o arquivo do source do Git~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh# Edite seu .bashrc~$ vim ~/.bashrc# Adicionando a seguinte linhasource ~/.git-completion.sh
  12. 12. git-completion# Copie o arquivo do source do Git~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh# Edite seu .bashrc~$ vim ~/.bashrc# Adicionando a seguinte linhasource ~/.git-completion.sh# Recarregue o ~/.bashrc~$ source ~/.bashrc
  13. 13. git-completion~$ git<tab><tab>
  14. 14. git-completion~$ git<tab><tab>add citool gc notes shortlogam clean get-tar-commit-id pull showannotate clone grep push show-branchapply co gui rebase starchive commit help relink stagebisect config imap-send remote stashblame describe init repack statusbr diff instaweb replace submodulebranch difftool log request-pull svnbundle fetch merge reset tagcheckout filter-branch mergetool revert whatchangedcherry format-patch mv rm winnercherry-pick fsck name-rev send-email
  15. 15. git-completion~$ git<tab><tab>add citool gc notes shortlogam clean get-tar-commit-id pull showannotate clone grep push show-branchapply co gui rebase starchive commit help relink stagebisect config imap-send remote stashblame describe init repack statusbr diff instaweb replace submodulebranch difftool log request-pull svnbundle fetch merge reset tagcheckout filter-branch mergetool revert whatchangedcherry format-patch mv rm winnercherry-pick fsck name-rev send-email~$ git re<tab><tab>
  16. 16. git-completion~$ git<tab><tab>add citool gc notes shortlogam clean get-tar-commit-id pull showannotate clone grep push show-branchapply co gui rebase starchive commit help relink stagebisect config imap-send remote stashblame describe init repack statusbr diff instaweb replace submodulebranch difftool log request-pull svnbundle fetch merge reset tagcheckout filter-branch mergetool revert whatchangedcherry format-patch mv rm winnercherry-pick fsck name-rev send-email~$ git re<tab><tab>rebase remote replace resetrelink repack request-pull revert~$
  17. 17. git-completion~$ git log --<tab><tab>
  18. 18. git-completion~$ git log --<tab><tab>--abbrev --dense --inter-hunk-context= --pretty=--abbrev-commit --diff-filter= --left-right --quiet--abbrev= --dirstat --max-age= --raw--after= --dirstat-by-file --max-count= --relative-date--all --dirstat-by-file= --merges --remotes--all-match --dirstat= --min-age= --reverse--author= --dst-prefix= --name-only --root--before= --exit-code --name-status --shortstat--binary --ext-diff --no-color --simplify-by-decoration--branches --find-copies-harder --no-ext-diff --simplify-merges--check --first-parent --no-merges --since=--cherry-pick --follow --no-prefix --sparse--children --format= --no-renames --src-prefix=--color --full-diff --not --stat--color-words --full-history --numstat --summary--committer= --full-index --oneline --tags--cumulative --graph --parents --text--date-order --grep= --patch-with-stat --topo-order--date= --ignore-all-space --patience --until=--More--
  19. 19. git-completion~$ git config core.<tab><tab>
  20. 20. git-completion~$ git config core.<tab><tab>core.autocrlf core.ignoreCygwinFSTricks core.repositoryFormatVersioncore.bare core.ignoreStat core.safecrlfcore.compression core.logAllRefUpdates core.sharedRepositorycore.createObject core.loosecompression core.symlinkscore.deltaBaseCacheLimit core.packedGitLimit core.trustctimecore.editor core.packedGitWindowSize core.warnAmbiguousRefscore.excludesfile core.pager core.whitespacecore.fileMode core.preferSymlinkRefs core.worktreecore.fsyncobjectfiles core.preloadindexcore.gitProxy core.quotepath~$
  21. 21. prompt
  22. 22. prompt# Edite seu .bashrc~$ vim ~/.bashrc# Adicionando a seguinte linhaexport PS1=w$(__git_ps1 "(%s)")# Recarregue o ~/.bashrc~$ source ~/.bashrc
  23. 23. prompt# Em um repositório git~$
  24. 24. prompt# Em um repositório git~$ cd git-tricks
  25. 25. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$
  26. 26. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-name
  27. 27. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$
  28. 28. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$
  29. 29. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$
  30. 30. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README
  31. 31. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$
  32. 32. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README
  33. 33. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$
  34. 34. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$
  35. 35. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash
  36. 36. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$
  37. 37. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$
  38. 38. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE
  39. 39. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE~/git-tricks(branch-name $%)$
  40. 40. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE~/git-tricks(branch-name $%)$ export GIT_PS1_SHOWUPSTREAM=auto
  41. 41. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE~/git-tricks(branch-name $%)$ export GIT_PS1_SHOWUPSTREAM=auto~/git-tricks(branch-name $%=)$ # branch local e origin estão em sincronia
  42. 42. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE~/git-tricks(branch-name $%)$ export GIT_PS1_SHOWUPSTREAM=auto~/git-tricks(branch-name $%=)$ # branch local e origin estão em sincronia~/git-tricks(branch-name $%>)$ # branch local está "a frente" do origin
  43. 43. prompt# Em um repositório git~$ cd git-tricks~/git-tricks(master)$ git checkout branch-nameSwitched to branch branch-name~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true~/git-tricks(branch-name)$ lsREADME~/git-tricks(branch-name)$ echo "Olá" >> README~/git-tricks(branch-name *)$ git add README~/git-tricks(branch-name +)$ export GIT_PS1_SHOWSTASHSTATE=true~/git-tricks(branch-name +)$ git stash~/git-tricks(branch-name $)$ export GIT_PS1_SHOWUNTRACKEDFILES=true~/git-tricks(branch-name $)$ touch NEWFILE~/git-tricks(branch-name $%)$ export GIT_PS1_SHOWUPSTREAM=auto~/git-tricks(branch-name $%=)$ # branch local e origin estão em sincronia~/git-tricks(branch-name $%>)$ # branch local está "a frente" do origin~/git-tricks(branch-name $%<)$ # branch local está "atrás" do origin
  44. 44. Configurações
  45. 45. core.excludesfile
  46. 46. core.excludesfile .gitignore global
  47. 47. core.excludesfile .gitignore global~$ git config --global core.excludesfile ~/.gitignore~$
  48. 48. core.excludesfile .gitignore global~$ git config --global core.excludesfile ~/.gitignore~$ cat ~/.gitignore.DS_Store.rvmrcetc...
  49. 49. help.format
  50. 50. help.format visualizar ajuda em HTML
  51. 51. help.format visualizar ajuda em HTML~$ git config --global help.format web
  52. 52. help.format visualizar ajuda em HTML~$ git config --global help.format web~$ git help commit
  53. 53. help.format visualizar ajuda em HTML~$ git config --global help.format web~$ git help commit
  54. 54. help.format visualizar ajuda em HTML~$ git config --global web.browser ff
  55. 55. help.format visualizar ajuda em HTML~$ git config --global web.browser ff~$ git config --global browser.ff.cmd "open -a Firefox.app"
  56. 56. help.format visualizar ajuda em HTML~$ git config --global web.browser ff~$ git config --global browser.ff.cmd "open -a Firefox.app"~$ git help commit
  57. 57. help.format visualizar ajuda em HTML~$ git config --global web.browser ff~$ git config --global browser.ff.cmd "open -a Firefox.app"~$ git help commit
  58. 58. push.default
  59. 59. push.default enviar apenas o branch atual
  60. 60. push.default enviar apenas o branch atual~$ git config --global push.default current
  61. 61. commit.template
  62. 62. commit.template template para a mensagem de commit
  63. 63. commit.template template para a mensagem de commit~$ cat ~/.commit-message.txtAssuntoO que eu fiz[ticket: X]
  64. 64. commit.template template para a mensagem de commit~$ cat ~/.commit-message.txtAssuntoO que eu fiz[ticket: X]~$ git config --global commit.template ~/.commit-message.txt
  65. 65. commit.template template para a mensagem de commit~$ cat ~/.commit-message.txtAssuntoO que eu fiz[ticket: X]~$ git config --global commit.template ~/.commit-message.txt~$ git commitAssuntoO que eu fiz[ticket: X]# Please enter the commit message for your changes. Lines starting# with # will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:
  66. 66. help.autocorrect
  67. 67. help.autocorrect roda o comando correto, mesmo se você digitou errado
  68. 68. help.autocorrect roda o comando correto, mesmo se você digitou errado~$ git statgit: stat is not a git command. See git --help.Did you mean this? status~$
  69. 69. help.autocorrect roda o comando correto, mesmo se você digitou errado~$ git statgit: stat is not a git command. See git --help.Did you mean this? status~$ git config --global help.autocorrect 1~$
  70. 70. help.autocorrect roda o comando correto, mesmo se você digitou errado~$ git statgit: stat is not a git command. See git --help.Did you mean this? status~$ git config --global help.autocorrect 1~$ git statWARNING: You called a Git command named stat, which does not exist.Continuing under the assumption that you meant statusin 0.1 seconds automatically...# On branch masternothing to commit (working directory clean)~$
  71. 71. branch.master.rebase
  72. 72. branch.master.rebase `git pull` no master sempre com rebase
  73. 73. branch.master.rebase `git pull` no master sempre com rebase~$ git config branch.master.rebase true# Chega de digitar `git pull --rebase`!
  74. 74. branch.autosetuprebase
  75. 75. branch.autosetuprebase `git pull` sempre com rebase em todos os “tracking branches”
  76. 76. branch.autosetuprebase `git pull` sempre com rebase em todos os “tracking branches”~$ git config --global branch.autosetuprebase always# Chega de digitar `git pull --rebase`!
  77. 77. Comandos
  78. 78. git commit --verbose
  79. 79. git commit --verbose Exibe um diff abaixo da mensagem de commit
  80. 80. git commit --verbose Exibe um diff abaixo da mensagem de commit~/git-tricks(master)$ echo "Mundo" >> README~/git-tricks(master *)$
  81. 81. git commit --verbose Exibe um diff abaixo da mensagem de commit~/git-tricks(master)$ echo "Mundo" >> README~/git-tricks(master *)$ git commit -a -v# Please enter the commit message for your changes. Lines starting# with # will be ignored, and an empty message aborts the commit.[...]#diff --git a/README b/READMEindex 1ca34a8..feae20b 100644--- a/README+++ b/README@@ -1 +1,2 @@ Olá+Mundo
  82. 82. git diff --word-diff
  83. 83. git diff --word-diff diff com destaque nas palavras
  84. 84. git diff --word-diff diff com destaque nas palavras~/git-tricks(master)$ git diffdiff --git a/README b/READMEindex 84dd63e..0cc3cbe 100644--- a/README+++ b/README@@ -1 +1 @@-Olá Mundo+Oi Mundo~/git-tricks(master)$
  85. 85. git diff --word-diff diff com destaque nas palavras~/git-tricks(master)$ git diffdiff --git a/README b/READMEindex 84dd63e..0cc3cbe 100644--- a/README+++ b/README@@ -1 +1 @@-Olá Mundo+Oi Mundo~/git-tricks(master)$ git diff --word-diffdiff --git a/README b/READMEindex 84dd63e..0cc3cbe 100644--- a/README+++ b/README@@ -1 +1 @@[-Olá-]{+Oi+} Mundo
  86. 86. git log --decorate
  87. 87. git log --decorate Exibe branches e tags no git log
  88. 88. git log --decorate Exibe branches e tags no git log~/git-tricks(fixes)$ git log --oneline --decoratefceaeb5 (HEAD, fixes) typoc1bcf8a (tag: v0.2.0) Fix80e9826 (origin/master, origin/HEAD, master) Second commit3247745 (tag: v0.1.0) Initial commit~/git-tricks(fixes)$
  89. 89. git status -s -b
  90. 90. git status -s -b mensagem de status curta
  91. 91. git status -s -b mensagem de status curta~/git-tricks(master)$ git status -s -b## master...origin/master [ahead 2, behind 3] M READMEA TODO?? LICENSE?? AUTHORS~/git-tricks(master)$
  92. 92. git push -u
  93. 93. git push -u envia um branch e configura o tracking
  94. 94. git push -u envia um branch e configura o tracking~/git-tricks(fixes)$ git push -u origin fixes * [new branch] fixes -> fixesBranch fixes set up to track remote branch fixes from origin.~/git-tricks(fixes)$
  95. 95. git checkout -t
  96. 96. git checkout -t cria, faz checkout e tracking de branches remotos
  97. 97. git checkout -t cria, faz checkout e tracking de branches remotos~/git-tricks(master)$ git checkout -t origin/fixesBranch fixes set up to track remote branch fixes from origin.Switched to a new branch fixes~/git-tricks(fixes)$
  98. 98. git branch
  99. 99. git branch visualizando informações dos branches
  100. 100. git branch visualizando informações dos branches~/git-tricks(master)$ git branchfixesi18n* masterrelease~/git-tricks(master)$
  101. 101. git branch visualizando informações dos branches~/git-tricks(master)$ git branchfixesi18n* masterrelease~/git-tricks(master)$ git branch --mergedfixes* master~/git-tricks(master)$
  102. 102. git branch visualizando informações dos branches~/git-tricks(master)$ git branchfixesi18n* masterrelease~/git-tricks(master)$ git branch --mergedfixes* master~/git-tricks(master)$ git branch --no-mergedi18nrelease~/git-tricks(master)$
  103. 103. git branch visualizando informações dos branches~/git-tricks(master)$ git branchfixesi18n* masterrelease~/git-tricks(master)$ git branch --mergedfixes* master~/git-tricks(master)$ git branch --no-mergedi18nrelease~/git-tricks(master)$ git branch --contains c1bcf8afixes* master~/git-tricks(master)$
  104. 104. git blame -L
  105. 105. git blame -L blame com range de linhas
  106. 106. git blame -L blame com range de linhas~/rails(master)$ git blame version.rbb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 1) module Railsb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 2) module VERSION #:nodoc:b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 3) MAJOR = 321b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0ccd2f3ed (Carl Lerche 2010-11-16 15:11:46 -0800 6) PRE = "beta"b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 7)ccd2f3ed (Carl Lerche 2010-11-16 15:11:46 -0800 8) STRING =b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 9) endb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 10) end~/rails(master)$
  107. 107. git blame -L blame com range de linhas~/rails(master)$ git blame version.rbb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 1) module Railsb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 2) module VERSION #:nodoc:b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 3) MAJOR = 321b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0ccd2f3ed (Carl Lerche 2010-11-16 15:11:46 -0800 6) PRE = "beta"b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 7)ccd2f3ed (Carl Lerche 2010-11-16 15:11:46 -0800 8) STRING =b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 9) endb1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 10) end~/rails(master)$ git blame -L 4,7 version.rb21b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0ccd2f3ed (Carl Lerche 2010-11-16 15:11:46 -0800 6) PRE = "beta"b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 7)~/rails(master)$
  108. 108. git blame -C
  109. 109. git blame -C blame com informações de onde o conteúdo veio
  110. 110. git blame -C blame com informações de onde o conteúdo veio~/rails(master)$ git blame -C -L 2,6 README.rdocb70062f1 README (José Valim 2010-07-21 12:37:05 +0200 2)3cd9627b README.rdoc (Xavier Noria 2010-08-21 02:23:04 +0200 3)dba196cb railties/README (Pratik Naik 2010-01-17 03:26:20 +0530 4)3e732780 railties/README (David Heinemeier Hansson 2008-03-29 18:45:39 +0000 5)1535b02a railties/README (Matt Di Pasquale 2010-03-24 02:17:09 -0400 6)~/rails(master)$
  111. 111. Features
  112. 112. stash
  113. 113. stash guarda as alterações em um “commit” temporário
  114. 114. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ echo "Hello World" >> README~/git-tricks(master)$ git status -s M README~/git-tricks(master)$
  115. 115. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ echo "Hello World" >> README~/git-tricks(master)$ git status -s M README~/git-tricks(master)$ git stashSaved working directory and index state WIP on master: 51e034d typoHEAD is now at 51e034d typo~/git-tricks(master)$
  116. 116. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ echo "Hello World" >> README~/git-tricks(master)$ git status -s M README~/git-tricks(master)$ git stashSaved working directory and index state WIP on master: 51e034d typoHEAD is now at 51e034d typo~/git-tricks(master)$ git status -s~/git-tricks(master)$ git stash liststash@{0}: WIP on master: 51e034d typo~/git-tricks(master)$
  117. 117. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ echo "Hello World" >> README~/git-tricks(master)$ git status -s M README~/git-tricks(master)$ git stashSaved working directory and index state WIP on master: 51e034d typoHEAD is now at 51e034d typo~/git-tricks(master)$ git status -s~/git-tricks(master)$ git stash liststash@{0}: WIP on master: 51e034d typo~/git-tricks(master)$ git show stash@{0}commit 2f7289f68669d3b5e70ecff1ba7e3ac4742135e9Merge: 51e034d 36167acAuthor: Arthur Zapparoli <arthurzap@gmail.com>Date: Wed Feb 20 20:23:47 2011 -0300
  118. 118. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ git stash pop~/git-tricks(master)$ git status -s M README~/git-tricks(master)$ git status list~/git-tricks(master)$
  119. 119. stash guarda as alterações em um “commit” temporário~/git-tricks(master)$ git stash pop~/git-tricks(master)$ git status -s M README~/git-tricks(master)$ git status list~/git-tricks(master)$ git stash save "mensagem"Saved working directory and index state On master: mensagemHEAD is now at 51e034d typo~/git-tricks(master)$ git stash liststash@{0}: On master: mensagem~/git-tricks(master)$
  120. 120. staging area
  121. 121. staging area tenho 2 arquivos, quero adicionar só 1
  122. 122. staging area tenho 2 arquivos, quero adicionar só 1~/git-tricks(master)$ git status# On branch master# Changed but not updated:## modified: AUTHORS# modified: README#no changes added to commit (use "git add" and/or "git commit -a")~/git-tricks(master)$
  123. 123. staging area tenho 2 arquivos, quero adicionar só 1~/git-tricks(master)$ git status# On branch master# Changed but not updated:## modified: AUTHORS# modified: README#no changes added to commit (use "git add" and/or "git commit -a")~/git-tricks(master)$ git add README~/git-tricks(master)$ git status# On branch master# Changes to be committed:## modified: README## Changed but not updated:## modified: AUTHORS#~/git-tricks(master)$
  124. 124. staging area tenho 2 arquivos, quero adicionar só 1~/git-tricks(master)$ git commit -m "English!"[master 76b2c02] English 1 files changed, 1 insertions(+), 0 deletions(-)~/git-tricks(master)$
  125. 125. staging area tenho 2 arquivos, quero adicionar só 1~/git-tricks(master)$ git commit -m "English!"[master 76b2c02] English 1 files changed, 1 insertions(+), 0 deletions(-)~/git-tricks(master)$ git status# On branch master# Changed but not updated:## modified: AUTHORS#no changes added to commit (use "git add" and/or "git commit -a")~/git-tricks(master)$
  126. 126. staging area quando eu quero adicionar apenas uma parte de um arquivo
  127. 127. staging area quando eu quero adicionar apenas uma parte de um arquivo~/git-tricks(master)$ git status -s M AUTHORS~/git-tricks(master)$
  128. 128. staging area quando eu quero adicionar apenas uma parte de um arquivo~/git-tricks(master)$ git status -s M AUTHORS~/git-tricks(master)$ git add -i*** Commands *** 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elpWhat now>
  129. 129. staging area quando eu quero adicionar apenas uma parte de um arquivo~/git-tricks(master)$ git status -s M AUTHORS~/git-tricks(master)$ git add -i*** Commands *** 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elpWhat now> 5 1: unchanged +2/-0 [A]UTHORSPatch update>> 1* 1: unchanged +2/-0 [A]UTHORSPatch update>>diff --git a/AUTHORS b/AUTHORSindex e69de29..5db9767 100644--- a/AUTHORS+++ b/AUTHORS@@ -0,0 +1,2 @@+Arthur+GuilhermeStage this hunk [y,n,q,a,d,/,e,?]?
  130. 130. staging area quando eu quero adicionar apenas uma parte de um arquivoStage this hunk [y,n,q,a,d,/,e,?]?y - stage this hunkn - do not stage this hunkq - quit; do not stage this hunk nor any of the remaining onesa - stage this hunk and all later hunks in the filed - do not stage this hunk nor any of the later hunks in the fileg - select a hunk to go to/ - search for a hunk matching the given regexj - leave this hunk undecided, see next undecided hunkJ - leave this hunk undecided, see next hunkk - leave this hunk undecided, see previous undecided hunkK - leave this hunk undecided, see previous hunks - split the current hunk into smaller hunkse - manually edit the current hunk? - print help@@ -0,0 +1,2 @@+Arthur+GuilhermeStage this hunk [y,n,q,a,d,/,e,?]?
  131. 131. staging area quando eu quero adicionar apenas uma parte de um arquivoStage this hunk [y,n,q,a,d,/,e,?]? e# Manual hunk edit mode -- see bottom for a quick guide@@ -0,0 +1,2 @@+Arthur+Guilherme# ---# To remove - lines, make them lines (context).# To remove + lines, delete them.# Lines starting with # will be removed.## If the patch applies cleanly, the edited hunk will immediately be# marked for staging. If it does not apply cleanly, you will be given# an opportunity to edit again. If all lines of the hunk are removed,# then the edit is aborted and the hunk is left unchanged.
  132. 132. staging area quando eu quero adicionar apenas uma parte de um arquivoStage this hunk [y,n,q,a,d,/,e,?]? e# Manual hunk edit mode -- see bottom for a quick guide@@ -0,0 +1,2 @@+Arthur+Guilherme# ---# To remove - lines, make them lines (context).# To remove + lines, delete them.# Lines starting with # will be removed.## If the patch applies cleanly, the edited hunk will immediately be# marked for staging. If it does not apply cleanly, you will be given# an opportunity to edit again. If all lines of the hunk are removed,# then the edit is aborted and the hunk is left unchanged.*** Commands *** 1: [s]tatus 2: [u]pdate 3: [r]evert 4: [a]dd untracked 5: [p]atch 6: [d]iff 7: [q]uit 8: [h]elpWhat now> 7Bye.~/git-tricks(master)$
  133. 133. staging area quando eu quero adicionar apenas uma parte de um arquivo~/git-tricks(master)$ git status# On branch master# Changes to be committed:## modified: AUTHORS## Changed but not updated:## modified: AUTHORS#~/git-tricks(master)$
  134. 134. rebase
  135. 135. rebase reaplica as mudanças de um branch em cima de outro
  136. 136. rebase reaplica as mudanças de um branch em cima de outro~/git-tricks(master)$ git branch authors* master~/git-tricks(master)$ git branch --no-merged authors~/git-tricks(master)$ git log --oneline --graph* f121878 Fix* 76b2c02 English[...]~/git-tricks(master)$
  137. 137. rebase reaplica as mudanças de um branch em cima de outro~/git-tricks(master)$ git branch authors* master~/git-tricks(master)$ git branch --no-merged authors~/git-tricks(master)$ git log --oneline --graph* f121878 Fix* 76b2c02 English[...]~/git-tricks(master)$ git merge authors~/git-tricks(master)$ git log --oneline --graph --decorate* c81cff6 (HEAD, master) Merge branch authors|| * 1e2f8a4 (authors) New Authors* | f121878 Fix|/* 76b2c02 English
  138. 138. rebase reaplica as mudanças de um branch em cima de outro~/git-tricks(master)$ git branch authors* master~/git-tricks(master)$ git branch --no-merged authors~/git-tricks(master)$ git log --oneline --graph* f121878 Fix* 76b2c02 English[...]~/git-tricks(master)$ git rebase authorsFirst, rewinding head to replay your work on top of it...Applying: Fix~/git-tricks(master)$ git log --oneline --graph --decorate* b28e647 (HEAD, master) Fix* 1e2f8a4 (authors) New Authors* 76b2c02 English
  139. 139. reescrevendo a história
  140. 140. reescrevendo a história editando o último commit
  141. 141. reescrevendo a história editando o último commit amend
  142. 142. reescrevendo a história editando o último commit~/git-tricks(master)$ git log --onelinefceaeb5 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ amend
  143. 143. reescrevendo a história editando o último commit~/git-tricks(master)$ git log --onelinefceaeb5 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ echo "." >> README~/git-tricks(master)$ git commit -a --amend[master 5dc6308] typo 1 files changed, 2 insertions(+), 1 deletions(-)~/git-tricks(master)$ amend
  144. 144. reescrevendo a história editando o último commit~/git-tricks(master)$ git log --onelinefceaeb5 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ echo "." >> README~/git-tricks(master)$ git commit -a --amend[master 5dc6308] typo 1 files changed, 2 insertions(+), 1 deletions(-)~/git-tricks(master)$ git log --oneline5dc6308 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ amend
  145. 145. reescrevendo a história editando o último commit~/git-tricks(master)$ git log --onelinefceaeb5 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ echo "." >> README~/git-tricks(master)$ git commit -a --amend[master 5dc6308] typo 1 files changed, 2 insertions(+), 1 deletions(-)~/git-tricks(master)$ git log --oneline5dc6308 typoc1bcf8a Fix80e9826 Second commit3247745 Initial commit~/git-tricks(master)$ amend
  146. 146. reescrevendo a história
  147. 147. reescrevendo a história editando vários commits de uma só vez
  148. 148. reescrevendo a história editando vários commits de uma só vez rebase -i
  149. 149. reescrevendo a história editando vários commits de uma só vez~/git-tricks(master)$ git log --onelineb28e647 Fix1e2f8a4 New Authors76b2c02 English~/git-tricks(master)$ rebase -i
  150. 150. reescrevendo a história editando vários commits de uma só vez~/git-tricks(master)$ git log --onelineb28e647 Fix1e2f8a4 New Authors76b2c02 English~/git-tricks(master)$ git rebase -i HEAD~3pick 76b2c02 Englishpick 1e2f8a4 New Authorspick b28e647 Fix# Rebase 76b2c02..b28e647 onto 76b2c02## 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 commits log message#### If you remove a line here THAT COMMIT WILL BE LOST. However, if you remove everything, the rebase will be aborted. rebase -i
  151. 151. reescrevendo a história editando vários commits de uma só vez~/git-tricks(master)$ git log --onelineb28e647 Fix1e2f8a4 New Authors76b2c02 English~/git-tricks(master)$ git rebase -i HEAD~3pick 76b2c02 Englishedit 1e2f8a4 New Authorspick b28e647 Fix# Rebase 76b2c02..b28e647 onto 76b2c02## 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 commits log message#### If you remove a line here THAT COMMIT WILL BE LOST. However, if you remove everything, the rebase will be aborted. rebase -i
  152. 152. reescrevendo a história editando vários commits de uma só vezStopped at 1e2f8a4... New AuthorsYou can amend the commit now, with git commit --amendOnce you are satisfied with your changes, run git rebase --continue~/git-tricks(master|REBASE-i)$ rebase -i
  153. 153. reescrevendo a história editando vários commits de uma só vezStopped at 1e2f8a4... New AuthorsYou can amend the commit now, with git commit --amendOnce you are satisfied with your changes, run git rebase --continue~/git-tricks(master|REBASE-i)$ git commit --amend[detached HEAD 0c434b4] New Authors: Arthur and Guilherme 1 files changed, 2 insertions(+), 0 deletions(-)~/git-tricks(master|REBASE-i)$ git rebase --continueSuccessfully rebased and updated refs/heads/master.~/git-tricks(master)$ git log --onelineedac081 Fix0c434b4 New Authors: Arthur and Guilherme76b2c02 English rebase -i
  154. 154. reescrevendo a história editando vários commits de uma só vezStopped at 1e2f8a4... New AuthorsYou can amend the commit now, with git commit --amendOnce you are satisfied with your changes, run git rebase --continue~/git-tricks(master|REBASE-i)$ git commit --amend[detached HEAD 0c434b4] New Authors: Arthur and Guilherme 1 files changed, 2 insertions(+), 0 deletions(-)~/git-tricks(master|REBASE-i)$ git rebase --continueSuccessfully rebased and updated refs/heads/master.~/git-tricks(master)$ git log --oneline Antes:edac081 Fix b28e647 Fix0c434b4 New Authors: Arthur and Guilherme 1e2f8a4 New Authors76b2c02 English 76b2c02 English rebase -i
  155. 155. reescrevendo a história reordenando commits~/git-tricks(master)$ git log --onelineedac081 Fix0c434b4 New Authors: Arthur and Guilherme76b2c02 English3933fbc Adding AUTHORS~/git-tricks(master)$ git rebase -i HEAD~4pick 3933fbc Adding AUTHORSpick 76b2c02 Englishpick 0c434b4 New Authors: Arthur and Guilhermepick edac081 Fix rebase -i
  156. 156. reescrevendo a história reordenando commits~/git-tricks(master)$ git log --onelineedac081 Fix0c434b4 New Authors: Arthur and Guilherme76b2c02 English3933fbc Adding AUTHORS~/git-tricks(master)$ git rebase -i HEAD~4pick 76b2c02 Englishpick edac081 Fixpick 3933fbc Adding AUTHORSpick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  157. 157. reescrevendo a história reordenando commits~/git-tricks(master)$ git log --onelineedac081 Fix0c434b4 New Authors: Arthur and Guilherme76b2c02 English3933fbc Adding AUTHORS~/git-tricks(master)$ git rebase -i HEAD~4pick 76b2c02 Englishpick edac081 Fixpick 3933fbc Adding AUTHORSpick 0c434b4 New Authors: Arthur and Guilherme~/git-tricks(master)$ git log --onelinec3187e3 New Authors: Arthur and Guilherme40a5b76 Adding AUTHORS76bc060 Fix36553c5 English~/git-tricks(master)$ rebase -i
  158. 158. reescrevendo a história deletando commits rebase -i
  159. 159. reescrevendo a história deletando commits~/git-tricks(master)$ git log --onelinec3187e3 New Authors: Arthur and Guilherme40a5b76 Adding AUTHORS76bc060 Fix36553c5 English~/git-tricks(master)$ git rebase -i HEAD~4pick 36553c5 Englishpick edac081 Fixpick 3933fbc Adding AUTHORSpick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  160. 160. reescrevendo a história deletando commits~/git-tricks(master)$ git log --onelinec3187e3 New Authors: Arthur and Guilherme40a5b76 Adding AUTHORS76bc060 Fix36553c5 English~/git-tricks(master)$ git rebase -i HEAD~4pick 36553c5 Englishpick 3933fbc Adding AUTHORSpick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  161. 161. reescrevendo a história deletando commits~/git-tricks(master)$ git log --onelinec3187e3 New Authors: Arthur and Guilherme40a5b76 Adding AUTHORS76bc060 Fix36553c5 English~/git-tricks(master)$ git rebase -i HEAD~4pick 36553c5 Englishpick 3933fbc Adding AUTHORSpick 0c434b4 New Authors: Arthur and Guilherme~/git-tricks(master)$ git log --onelinef648606 New Authors: Arthur and Guilherme373183d Adding AUTHORS36553c5 English~/git-tricks(master)$ rebase -i
  162. 162. reescrevendo a história juntando commits rebase -i
  163. 163. reescrevendo a história juntando commits~/git-tricks(master)$ git log --onelinef648606 New Authors: Arthur and Guilherme373183d Adding AUTHORS36553c5 English~/git-tricks(master)$ git rebase -i HEAD~3pick 36553c5 Englishpick 373183d Adding AUTHORSpick f648606 New Authors: Arthur and Guilherme rebase -i
  164. 164. reescrevendo a história juntando commits~/git-tricks(master)$ git log --onelinef648606 New Authors: Arthur and Guilherme373183d Adding AUTHORS36553c5 English~/git-tricks(master)$ git rebase -i HEAD~3pick 36553c5 Englishpick 373183d Adding AUTHORSsquash f648606 New Authors: Arthur and Guilherme rebase -i
  165. 165. reescrevendo a história juntando commits~/git-tricks(master)$ git log --onelinef648606 New Authors: Arthur and Guilherme373183d Adding AUTHORS36553c5 English~/git-tricks(master)$ git rebase -i HEAD~3pick 36553c5 Englishpick 373183d Adding AUTHORSsquash f648606 New Authors: Arthur and Guilherme~/git-tricks(master)$# This is a combination of 2 commits.# The first commits message is:Adding AUTHORS# This is the 2nd commit message:New Authors: Arthur and Guilherme# Please enter the commit message for your changes. Lines starting# with # will be ignored, and an empty message aborts the commit. rebase -i
  166. 166. reescrevendo a história juntando commits[detached HEAD 8f851b8] Adding AUTHORS 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 AUTHORSSuccessfully rebased and updated refs/heads/master.~/git-tricks(master)$ git log --oneline8f851b8 Adding AUTHORS36553c5 English~/git-tricks(master)$ rebase -i
  167. 167. bisect ajuda a encontrar onde foram introduzidos bugs
  168. 168. cherry-pick escolha quais commits fazer merge
  169. 169. format-patch cria patches à partir de commits
  170. 170. reflog recupera dados perdidos
  171. 171. attributes define como trabalhar com arquivos binários
  172. 172. rererelembra resoluções de conflitos e as aplica automaticamente na próxima vez
  173. 173. garbage collector remove objetos obsoletos
  174. 174. notes adiciona notas aos seus commits
  175. 175. bundlesuma maneira melhor de “exportar” repositórios
  176. 176. e muito mais...
  177. 177. Git: do zero a samurai egenial.com.br/git
  178. 178. Dúvidas?
  179. 179. Obrigado!

×