SlideShare une entreprise Scribd logo
1  sur  179
Télécharger pour lire hors ligne
Git Tricks
  Arthur Zapparoli
   @arthurgeek
Tópicos
Ambiente
Ambiente


     Configurações
Ambiente


     Configurações

           Comandos
Ambiente


     Configurações

           Comandos

              Features
Ambiente
git-completion
git-completion
# Copie o arquivo do source do Git

~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh
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
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 linha

source ~/.git-completion.sh
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 linha

source ~/.git-completion.sh

# Recarregue o ~/.bashrc

~$ source ~/.bashrc
git-completion
~$ git<tab><tab>
git-completion
~$ git<tab><tab>
add                citool          gc                  notes          shortlog
am                 clean           get-tar-commit-id   pull           show
annotate           clone           grep                push           show-branch
apply              co              gui                 rebase         st
archive            commit          help                relink         stage
bisect             config          imap-send           remote         stash
blame              describe        init                repack         status
br                 diff            instaweb            replace        submodule
branch             difftool        log                 request-pull   svn
bundle             fetch           merge               reset          tag
checkout           filter-branch   mergetool           revert         whatchanged
cherry             format-patch    mv                  rm             winner
cherry-pick        fsck            name-rev            send-email
git-completion
~$ git<tab><tab>
add                   citool          gc                  notes          shortlog
am                    clean           get-tar-commit-id   pull           show
annotate              clone           grep                push           show-branch
apply                 co              gui                 rebase         st
archive               commit          help                relink         stage
bisect                config          imap-send           remote         stash
blame                 describe        init                repack         status
br                    diff            instaweb            replace        submodule
branch                difftool        log                 request-pull   svn
bundle                fetch           merge               reset          tag
checkout              filter-branch   mergetool           revert         whatchanged
cherry                format-patch    mv                  rm             winner
cherry-pick           fsck            name-rev            send-email

~$ git re<tab><tab>
git-completion
~$ git<tab><tab>
add                 citool              gc                  notes          shortlog
am                  clean               get-tar-commit-id   pull           show
annotate            clone               grep                push           show-branch
apply               co                  gui                 rebase         st
archive             commit              help                relink         stage
bisect              config              imap-send           remote         stash
blame               describe            init                repack         status
br                  diff                instaweb            replace        submodule
branch              difftool            log                 request-pull   svn
bundle              fetch               merge               reset          tag
checkout            filter-branch       mergetool           revert         whatchanged
cherry              format-patch        mv                  rm             winner
cherry-pick         fsck                name-rev            send-email

~$ git re<tab><tab>
rebase         remote         replace        reset
relink         repack         request-pull   revert
~$
git-completion
~$ git log --<tab><tab>
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--
git-completion
~$ git config core.<tab><tab>
git-completion
~$ git config core.<tab><tab>
core.autocrlf                   core.ignoreCygwinFSTricks   core.repositoryFormatVersion
core.bare                       core.ignoreStat             core.safecrlf
core.compression                core.logAllRefUpdates       core.sharedRepository
core.createObject               core.loosecompression       core.symlinks
core.deltaBaseCacheLimit        core.packedGitLimit         core.trustctime
core.editor                     core.packedGitWindowSize    core.warnAmbiguousRefs
core.excludesfile               core.pager                  core.whitespace
core.fileMode                   core.preferSymlinkRefs      core.worktree
core.fsyncobjectfiles           core.preloadindex
core.gitProxy                   core.quotepath
~$
prompt
prompt
# Edite seu .bashrc

~$ vim ~/.bashrc

# Adicionando a seguinte linha

export PS1='w$(__git_ps1 "(%s)")'

# Recarregue o ~/.bashrc

~$ source ~/.bashrc
prompt
# Em um repositório git

~$
prompt
# Em um repositório git

~$ cd git-tricks
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/git-tricks(branch-name)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/git-tricks(branch-name)$ echo "Olá" >> README
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/git-tricks(branch-name)$ echo "Olá" >> README
~/git-tricks(branch-name *)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/git-tricks(branch-name)$ echo "Olá" >> README
~/git-tricks(branch-name *)$ git add README
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/git-tricks(branch-name)$ echo "Olá" >> README
~/git-tricks(branch-name *)$ git add README
~/git-tricks(branch-name +)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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 +)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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 $)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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 $)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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 $%)$
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
prompt
# Em um repositório git

~$ cd git-tricks
~/git-tricks(master)$ git checkout branch-name
Switched to branch 'branch-name'
~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true
~/git-tricks(branch-name)$ ls
README
~/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
Configurações
core.excludesfile
core.excludesfile
                   .gitignore global
core.excludesfile
                                                  .gitignore global
~$ git config --global core.excludesfile ~/.gitignore
~$
core.excludesfile
                                                  .gitignore global
~$ git config --global core.excludesfile ~/.gitignore
~$ cat ~/.gitignore

.DS_Store
.rvmrc
etc...
help.format
help.format
              visualizar ajuda em HTML
help.format
                                   visualizar ajuda em HTML
~$ git config --global help.format web
help.format
                                   visualizar ajuda em HTML
~$ git config --global help.format web
~$ git help commit
help.format
                                   visualizar ajuda em HTML
~$ git config --global help.format web
~$ git help commit
help.format
                                   visualizar ajuda em HTML
~$ git config --global web.browser ff
help.format
                                   visualizar ajuda em HTML
~$ git config --global web.browser ff
~$ git config --global browser.ff.cmd "open -a Firefox.app"
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
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
push.default
push.default
           enviar apenas o branch atual
push.default
                               enviar apenas o branch atual
~$ git config --global push.default current
commit.template
commit.template
     template para a mensagem de commit
commit.template
                   template para a mensagem de commit
~$ cat ~/.commit-message.txt
Assunto

O que eu fiz

[ticket: X]
commit.template
                   template para a mensagem de commit
~$ cat ~/.commit-message.txt
Assunto

O que eu fiz

[ticket: X]
~$ git config --global commit.template ~/.commit-message.txt
commit.template
                   template para a mensagem de commit
~$ cat ~/.commit-message.txt
Assunto

O que eu fiz

[ticket: X]
~$ git config --global commit.template ~/.commit-message.txt
~$ git commit
Assunto

O 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:
help.autocorrect
help.autocorrect
   roda o comando correto, mesmo se você digitou errado
help.autocorrect
           roda o comando correto, mesmo se você digitou errado

~$ git stat
git: 'stat' is not a git command. See 'git --help'.

Did you mean this?
	 status
~$
help.autocorrect
           roda o comando correto, mesmo se você digitou errado

~$ git stat
git: 'stat' is not a git command. See 'git --help'.

Did you mean this?
	 status
~$ git config --global help.autocorrect 1
~$
help.autocorrect
           roda o comando correto, mesmo se você digitou errado

~$ git stat
git: 'stat' is not a git command. See 'git --help'.

Did you mean this?
	 status
~$ git config --global help.autocorrect 1
~$ git stat
WARNING: You called a Git command named 'stat', which does not exist.
Continuing under the assumption that you meant 'status'
in 0.1 seconds automatically...
# On branch master
nothing to commit (working directory clean)
~$
branch.master.rebase
branch.master.rebase
     `git pull` no master sempre com rebase
branch.master.rebase
                `git pull` no master sempre com rebase
~$ git config branch.master.rebase true

# Chega de digitar `git pull --rebase`!
branch.autosetuprebase
branch.autosetuprebase
  `git pull` sempre com rebase em todos os “tracking branches”
branch.autosetuprebase
         `git pull` sempre com rebase em todos os “tracking branches”


~$ git config --global branch.autosetuprebase always

# Chega de digitar `git pull --rebase`!
Comandos
git commit --verbose
git commit --verbose
       Exibe um diff abaixo da mensagem de commit
git commit --verbose
                       Exibe um diff abaixo da mensagem de commit

~/git-tricks(master)$ echo "Mundo" >> README
~/git-tricks(master *)$
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/README
index 1ca34a8..feae20b 100644
--- a/README
+++ b/README
@@ -1 +1,2 @@
  Olá
+Mundo
git diff --word-diff
git diff --word-diff
            diff com destaque nas palavras
git diff --word-diff
                             diff com destaque nas palavras
~/git-tricks(master)$ git diff
diff --git a/README b/README
index 84dd63e..0cc3cbe 100644
--- a/README
+++ b/README
@@ -1 +1 @@
-Olá Mundo
+Oi Mundo
~/git-tricks(master)$
git diff --word-diff
                             diff com destaque nas palavras
~/git-tricks(master)$ git diff
diff --git a/README b/README
index 84dd63e..0cc3cbe 100644
--- a/README
+++ b/README
@@ -1 +1 @@
-Olá Mundo
+Oi Mundo
~/git-tricks(master)$ git diff --word-diff
diff --git a/README b/README
index 84dd63e..0cc3cbe 100644
--- a/README
+++ b/README
@@ -1 +1 @@
[-Olá-]{+Oi+} Mundo
git log --decorate
git log --decorate
          Exibe branches e tags no git log
git log --decorate
                           Exibe branches e tags no git log
~/git-tricks(fixes)$ git log --oneline --decorate
fceaeb5 (HEAD, fixes) typo
c1bcf8a (tag: v0.2.0) Fix
80e9826 (origin/master, origin/HEAD, master) Second commit
3247745 (tag: v0.1.0) Initial commit
~/git-tricks(fixes)$
git status -s -b
git status -s -b
              mensagem de status curta
git status -s -b
                                   mensagem de status curta
~/git-tricks(master)$ git status -s -b
## master...origin/master [ahead 2, behind 3]
   M README
A     TODO
??     LICENSE
??     AUTHORS
~/git-tricks(master)$
git push -u
git push -u
     envia um branch e configura o tracking
git push -u
                envia um branch e configura o tracking
~/git-tricks(fixes)$ git push -u origin fixes
 * [new branch]      fixes -> fixes
Branch fixes set up to track remote branch fixes from origin.
~/git-tricks(fixes)$
git checkout -t
git checkout -t
      cria, faz checkout e tracking de branches remotos
git checkout -t
                  cria, faz checkout e tracking de branches remotos

~/git-tricks(master)$ git checkout -t origin/fixes
Branch fixes set up to track remote branch fixes from origin.
Switched to a new branch 'fixes'
~/git-tricks(fixes)$
git branch
git branch
     visualizando informações dos branches
git branch
                visualizando informações dos branches
~/git-tricks(master)$ git branch
fixes
i18n
* master
release
~/git-tricks(master)$
git branch
                visualizando informações dos branches
~/git-tricks(master)$ git branch
fixes
i18n
* master
release
~/git-tricks(master)$ git branch --merged
fixes
* master
~/git-tricks(master)$
git branch
                visualizando informações dos branches
~/git-tricks(master)$ git branch
fixes
i18n
* master
release
~/git-tricks(master)$ git branch --merged
fixes
* master
~/git-tricks(master)$ git branch --no-merged
i18n
release
~/git-tricks(master)$
git branch
                visualizando informações dos branches
~/git-tricks(master)$   git branch
fixes
i18n
* master
release
~/git-tricks(master)$   git branch --merged
fixes
* master
~/git-tricks(master)$   git branch --no-merged
i18n
release
~/git-tricks(master)$   git branch --contains c1bcf8a
fixes
* master
~/git-tricks(master)$
git blame -L
git blame -L
               blame com range de linhas
git blame -L
                                          blame com range de linhas
~/rails(master)$ git blame version.rb
b1769fe0 (Bryan Helmkamp           2010-03-01   23:02:55   -0500 1) module Rails
b1769fe0 (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 = 3
21b1f297 (David Heinemeier Hansson 2010-08-23   21:44:57   -0500 4)      MINOR = 1
b1769fe0 (Bryan Helmkamp           2010-03-01   23:02:55   -0500 5)      TINY = 0
ccd2f3ed (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)    end
b1769fe0 (Bryan Helmkamp           2010-03-01   23:02:55   -0500 10) end
~/rails(master)$
git blame -L
                                            blame com range de linhas
~/rails(master)$ git blame   version.rb
b1769fe0 (Bryan Helmkamp             2010-03-01   23:02:55   -0500 1) module Rails
b1769fe0 (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 = 3
21b1f297 (David Heinemeier   Hansson 2010-08-23   21:44:57   -0500 4)      MINOR = 1
b1769fe0 (Bryan Helmkamp             2010-03-01   23:02:55   -0500 5)      TINY = 0
ccd2f3ed (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)    end
b1769fe0 (Bryan Helmkamp             2010-03-01   23:02:55   -0500 10) end
~/rails(master)$ git blame   -L 4,7 version.rb
21b1f297 (David Heinemeier   Hansson 2010-08-23   21:44:57   -0500   4)   MINOR = 1
b1769fe0 (Bryan Helmkamp             2010-03-01   23:02:55   -0500   5)   TINY = 0
ccd2f3ed (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)$
git blame -C
git blame -C
      blame com informações de onde o conteúdo veio
git blame -C
                   blame com informações de onde o conteúdo veio

~/rails(master)$ git blame -C -L 2,6 README.rdoc
b70062f1 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)$
Features
stash
stash
        guarda as alterações em um “commit” temporário
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)$
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 stash
Saved working directory and index state WIP on master: 51e034d typo
HEAD is now at 51e034d typo
~/git-tricks(master)$
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 stash
Saved working directory and index state WIP on master: 51e034d typo
HEAD is now at 51e034d typo
~/git-tricks(master)$ git status -s
~/git-tricks(master)$ git stash list
stash@{0}: WIP on master: 51e034d typo
~/git-tricks(master)$
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 stash
Saved working directory and index state WIP on master: 51e034d typo
HEAD is now at 51e034d typo
~/git-tricks(master)$ git status -s
~/git-tricks(master)$ git stash list
stash@{0}: WIP on master: 51e034d typo
~/git-tricks(master)$ git show stash@{0}
commit 2f7289f68669d3b5e70ecff1ba7e3ac4742135e9
Merge: 51e034d 36167ac
Author: Arthur Zapparoli <arthurzap@gmail.com>
Date:   Wed Feb 20 20:23:47 2011 -0300
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)$
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: mensagem
HEAD is now at 51e034d typo
~/git-tricks(master)$ git stash list
stash@{0}: On master: mensagem
~/git-tricks(master)$
staging area
staging area
      tenho 2 arquivos, quero adicionar só 1
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)$
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)$
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)$
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)$
staging area
  quando eu quero adicionar apenas uma parte de um arquivo
staging area
         quando eu quero adicionar apenas uma parte de um arquivo

~/git-tricks(master)$ git status -s
 M AUTHORS
~/git-tricks(master)$
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]elp
What now>
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]elp
What now> 5
  1:    unchanged        +2/-0 [A]UTHORS
Patch update>> 1
* 1:    unchanged        +2/-0 [A]UTHORS
Patch update>>
diff --git a/AUTHORS b/AUTHORS
index e69de29..5db9767 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Arthur
+Guilherme
Stage this hunk [y,n,q,a,d,/,e,?]?
staging area
         quando eu quero adicionar apenas uma parte de um arquivo

Stage this hunk [y,n,q,a,d,/,e,?]?
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
@@ -0,0 +1,2 @@
+Arthur
+Guilherme
Stage this hunk [y,n,q,a,d,/,e,?]?
staging area
         quando eu quero adicionar apenas uma parte de um arquivo

Stage 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.
staging area
         quando eu quero adicionar apenas uma parte de um arquivo

Stage 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]elp
What now> 7
Bye.
~/git-tricks(master)$
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)$
rebase
rebase
    reaplica as mudanças de um branch em cima de outro
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)$
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
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 authors
First, 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
reescrevendo a história
reescrevendo a história
            editando o último commit
reescrevendo a história
            editando o último commit




                            amend
reescrevendo a história
                                   editando o último commit
~/git-tricks(master)$ git log --oneline
fceaeb5 typo
c1bcf8a Fix
80e9826 Second commit
3247745 Initial commit
~/git-tricks(master)$




                                                   amend
reescrevendo a história
                                   editando o último commit
~/git-tricks(master)$ git log --oneline
fceaeb5 typo
c1bcf8a Fix
80e9826 Second commit
3247745 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
reescrevendo a história
                                   editando o último commit
~/git-tricks(master)$ git log --oneline
fceaeb5 typo
c1bcf8a Fix
80e9826 Second commit
3247745 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 --oneline
5dc6308 typo
c1bcf8a Fix
80e9826 Second commit
3247745 Initial commit
~/git-tricks(master)$                               amend
reescrevendo a história
                                   editando o último commit
~/git-tricks(master)$ git log --oneline
fceaeb5 typo
c1bcf8a Fix
80e9826 Second commit
3247745 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 --oneline
5dc6308 typo
c1bcf8a Fix
80e9826 Second commit
3247745 Initial commit
~/git-tricks(master)$                               amend
reescrevendo a história
reescrevendo a história
     editando vários commits de uma só vez
reescrevendo a história
     editando vários commits de uma só vez




                               rebase -i
reescrevendo a história
                   editando vários commits de uma só vez
~/git-tricks(master)$ git log --oneline
b28e647 Fix
1e2f8a4 New Authors
76b2c02 English
~/git-tricks(master)$




                                             rebase -i
reescrevendo a história
                     editando vários commits de uma só vez
~/git-tricks(master)$ git log --oneline
b28e647 Fix
1e2f8a4 New Authors
76b2c02 English
~/git-tricks(master)$ git rebase -i HEAD~3
pick 76b2c02 English
pick 1e2f8a4 New Authors
pick 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 commit's 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
reescrevendo a história
                     editando vários commits de uma só vez
~/git-tricks(master)$ git log --oneline
b28e647 Fix
1e2f8a4 New Authors
76b2c02 English
~/git-tricks(master)$ git rebase -i HEAD~3
pick 76b2c02 English
edit 1e2f8a4 New Authors
pick 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 commit's 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
reescrevendo a história
                   editando vários commits de uma só vez
Stopped at 1e2f8a4... New Authors
You can amend the commit now, with

	   git commit --amend

Once you are satisfied with your changes, run

	   git rebase --continue

~/git-tricks(master|REBASE-i)$




                                                rebase -i
reescrevendo a história
                   editando vários commits de uma só vez
Stopped at 1e2f8a4... New Authors
You can amend the commit now, with

	   git commit --amend

Once 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 --continue
Successfully rebased and updated refs/heads/master.
~/git-tricks(master)$ git log --oneline
edac081 Fix
0c434b4 New Authors: Arthur and Guilherme
76b2c02 English

                                                            rebase -i
reescrevendo a história
                   editando vários commits de uma só vez
Stopped at 1e2f8a4... New Authors
You can amend the commit now, with

	   git commit --amend

Once 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 --continue
Successfully rebased and updated refs/heads/master.
~/git-tricks(master)$ git log --oneline              Antes:
edac081 Fix                                           b28e647 Fix
0c434b4 New Authors: Arthur and Guilherme             1e2f8a4 New Authors
76b2c02 English                                       76b2c02 English

                                                                            rebase -i
reescrevendo a história
                                                 reordenando commits
~/git-tricks(master)$ git log --oneline
edac081 Fix
0c434b4 New Authors: Arthur and Guilherme
76b2c02 English
3933fbc Adding AUTHORS
~/git-tricks(master)$ git rebase -i HEAD~4
pick 3933fbc Adding AUTHORS
pick 76b2c02 English
pick 0c434b4 New Authors: Arthur and Guilherme
pick edac081 Fix




                                                          rebase -i
reescrevendo a história
                                                 reordenando commits
~/git-tricks(master)$ git log --oneline
edac081 Fix
0c434b4 New Authors: Arthur and Guilherme
76b2c02 English
3933fbc Adding AUTHORS
~/git-tricks(master)$ git rebase -i HEAD~4
pick 76b2c02 English
pick edac081 Fix
pick 3933fbc Adding AUTHORS
pick 0c434b4 New Authors: Arthur and Guilherme




                                                          rebase -i
reescrevendo a história
                                                 reordenando commits
~/git-tricks(master)$ git log --oneline
edac081 Fix
0c434b4 New Authors: Arthur and Guilherme
76b2c02 English
3933fbc Adding AUTHORS
~/git-tricks(master)$ git rebase -i HEAD~4
pick 76b2c02 English
pick edac081 Fix
pick 3933fbc Adding AUTHORS
pick 0c434b4 New Authors: Arthur and Guilherme

~/git-tricks(master)$ git log --oneline
c3187e3 New Authors: Arthur and Guilherme
40a5b76 Adding AUTHORS
76bc060 Fix
36553c5 English
~/git-tricks(master)$



                                                          rebase -i
reescrevendo a história
                deletando commits




                       rebase -i
reescrevendo a história
                                                 deletando commits
~/git-tricks(master)$ git log --oneline
c3187e3 New Authors: Arthur and Guilherme
40a5b76 Adding AUTHORS
76bc060 Fix
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~4
pick 36553c5 English
pick edac081 Fix
pick 3933fbc Adding AUTHORS
pick 0c434b4 New Authors: Arthur and Guilherme




                                                        rebase -i
reescrevendo a história
                                                 deletando commits
~/git-tricks(master)$ git log --oneline
c3187e3 New Authors: Arthur and Guilherme
40a5b76 Adding AUTHORS
76bc060 Fix
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~4
pick 36553c5 English
pick 3933fbc Adding AUTHORS
pick 0c434b4 New Authors: Arthur and Guilherme




                                                        rebase -i
reescrevendo a história
                                                 deletando commits
~/git-tricks(master)$ git log --oneline
c3187e3 New Authors: Arthur and Guilherme
40a5b76 Adding AUTHORS
76bc060 Fix
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~4
pick 36553c5 English
pick 3933fbc Adding AUTHORS
pick 0c434b4 New Authors: Arthur and Guilherme

~/git-tricks(master)$ git log --oneline
f648606 New Authors: Arthur and Guilherme
373183d Adding AUTHORS
36553c5 English
~/git-tricks(master)$




                                                        rebase -i
reescrevendo a história
                 juntando commits




                       rebase -i
reescrevendo a história
                                                 juntando commits
~/git-tricks(master)$ git log --oneline
f648606 New Authors: Arthur and Guilherme
373183d Adding AUTHORS
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~3
pick 36553c5 English
pick 373183d Adding AUTHORS
pick f648606 New Authors: Arthur and Guilherme




                                                       rebase -i
reescrevendo a história
                                                   juntando commits
~/git-tricks(master)$ git log --oneline
f648606 New Authors: Arthur and Guilherme
373183d Adding AUTHORS
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~3
pick 36553c5 English
pick 373183d Adding AUTHORS
squash f648606 New Authors: Arthur and Guilherme




                                                         rebase -i
reescrevendo a história
                                                            juntando commits
~/git-tricks(master)$ git log --oneline
f648606 New Authors: Arthur and Guilherme
373183d Adding AUTHORS
36553c5 English
~/git-tricks(master)$ git rebase -i HEAD~3
pick 36553c5 English
pick 373183d Adding AUTHORS
squash f648606 New Authors: Arthur and Guilherme

~/git-tricks(master)$
# This is a combination of 2 commits.
# The first commit's 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
reescrevendo a história
                                                      juntando commits
[detached HEAD 8f851b8] Adding AUTHORS
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 AUTHORS
Successfully rebased and updated refs/heads/master.
~/git-tricks(master)$ git log --oneline
8f851b8 Adding AUTHORS
36553c5 English
~/git-tricks(master)$




                                                            rebase -i
bisect
         ajuda a encontrar onde foram introduzidos bugs
cherry-pick
       escolha quais commits fazer merge
format-patch
        cria patches à partir de commits
reflog
        recupera dados perdidos
attributes
         define como trabalhar com arquivos binários
rerere
lembra resoluções de conflitos e as aplica automaticamente na próxima vez
garbage collector
            remove objetos obsoletos
notes
        adiciona notas aos seus commits
bundles
uma maneira melhor de “exportar” repositórios
e muito mais...
Git: do zero a samurai
                    egenial.com.br/git
Dúvidas?
Obrigado!

Contenu connexe

Tendances

linux_Commads
linux_Commadslinux_Commads
linux_Commadstastedone
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...Codemotion
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaiCreateWorld
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统yiditushe
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on LinuxTushar B Kute
 
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)Karel Minarik
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous TaskErin Dees
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsManav Prasad
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117exsuns
 
Introduction to linux day1
Introduction to linux day1Introduction to linux day1
Introduction to linux day1Gourav Varma
 
Hadoop 20111215
Hadoop 20111215Hadoop 20111215
Hadoop 20111215exsuns
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparisonarunkumar sadhasivam
 

Tendances (20)

linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...
Thijs Feryn - Leverage HTTP to deliver cacheable websites - Codemotion Milan ...
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Facebook的缓存系统
Facebook的缓存系统Facebook的缓存系统
Facebook的缓存系统
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
Pdf sample3
Pdf sample3Pdf sample3
Pdf sample3
 
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
Shell's Kitchen: Infrastructure As Code (Webexpo 2012)
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous Task
 
Linux system admin
Linux system adminLinux system admin
Linux system admin
 
Bash 4
Bash 4Bash 4
Bash 4
 
Railsconf
RailsconfRailsconf
Railsconf
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
High Performance tDiary
High Performance tDiaryHigh Performance tDiary
High Performance tDiary
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
 
Introduction to linux day1
Introduction to linux day1Introduction to linux day1
Introduction to linux day1
 
Git
GitGit
Git
 
Hadoop 20111215
Hadoop 20111215Hadoop 20111215
Hadoop 20111215
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Aix0107
Aix0107Aix0107
Aix0107
 
Hadoop spark performance comparison
Hadoop spark performance comparisonHadoop spark performance comparison
Hadoop spark performance comparison
 

Similaire à Git Tricks

GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceForest Mars
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!Atlassian
 
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]Carina C. Zona
 
Git for beginners
Git for beginnersGit for beginners
Git for beginnersVinh Nguyen
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X ServerYasuhiro Asaka
 
Git Tutorial Yang Yang
Git Tutorial Yang YangGit Tutorial Yang Yang
Git Tutorial Yang YangYang Yang
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Git major commands
Git major commandsGit major commands
Git major commandsmyepicslides
 
Git major commands
Git major commandsGit major commands
Git major commandsmyepicslides
 
Essential git fu for tech writers
Essential git fu for tech writersEssential git fu for tech writers
Essential git fu for tech writersGaurav Nelson
 
Openstack presentation
Openstack presentationOpenstack presentation
Openstack presentationbodepd
 

Similaire à Git Tricks (20)

GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
T3dd10 git
T3dd10 gitT3dd10 git
T3dd10 git
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
 
181220_slideshare_git
181220_slideshare_git181220_slideshare_git
181220_slideshare_git
 
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X Server
 
git internals
git internalsgit internals
git internals
 
Git
GitGit
Git
 
Git Tutorial Yang Yang
Git Tutorial Yang YangGit Tutorial Yang Yang
Git Tutorial Yang Yang
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Git avançado
Git avançadoGit avançado
Git avançado
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git major commands
Git major commandsGit major commands
Git major commands
 
Git major commands
Git major commandsGit major commands
Git major commands
 
Essential git fu for tech writers
Essential git fu for tech writersEssential git fu for tech writers
Essential git fu for tech writers
 
Openstack presentation
Openstack presentationOpenstack presentation
Openstack presentation
 
Git basics
Git basicsGit basics
Git basics
 
EC2
EC2EC2
EC2
 

Dernier

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 

Dernier (20)

Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 

Git Tricks

  • 1. Git Tricks Arthur Zapparoli @arthurgeek
  • 4. Ambiente Configurações
  • 5. Ambiente Configurações Comandos
  • 6. Ambiente Configurações Comandos Features
  • 9. git-completion # Copie o arquivo do source do Git ~$ cp $GIT_SOURCE/contrib/completion/git-completion.bash ~/.git-completion.sh
  • 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. 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 linha source ~/.git-completion.sh
  • 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 linha source ~/.git-completion.sh # Recarregue o ~/.bashrc ~$ source ~/.bashrc
  • 14. git-completion ~$ git<tab><tab> add citool gc notes shortlog am clean get-tar-commit-id pull show annotate clone grep push show-branch apply co gui rebase st archive commit help relink stage bisect config imap-send remote stash blame describe init repack status br diff instaweb replace submodule branch difftool log request-pull svn bundle fetch merge reset tag checkout filter-branch mergetool revert whatchanged cherry format-patch mv rm winner cherry-pick fsck name-rev send-email
  • 15. git-completion ~$ git<tab><tab> add citool gc notes shortlog am clean get-tar-commit-id pull show annotate clone grep push show-branch apply co gui rebase st archive commit help relink stage bisect config imap-send remote stash blame describe init repack status br diff instaweb replace submodule branch difftool log request-pull svn bundle fetch merge reset tag checkout filter-branch mergetool revert whatchanged cherry format-patch mv rm winner cherry-pick fsck name-rev send-email ~$ git re<tab><tab>
  • 16. git-completion ~$ git<tab><tab> add citool gc notes shortlog am clean get-tar-commit-id pull show annotate clone grep push show-branch apply co gui rebase st archive commit help relink stage bisect config imap-send remote stash blame describe init repack status br diff instaweb replace submodule branch difftool log request-pull svn bundle fetch merge reset tag checkout filter-branch mergetool revert whatchanged cherry format-patch mv rm winner cherry-pick fsck name-rev send-email ~$ git re<tab><tab> rebase remote replace reset relink repack request-pull revert ~$
  • 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. git-completion ~$ git config core.<tab><tab>
  • 20. git-completion ~$ git config core.<tab><tab> core.autocrlf core.ignoreCygwinFSTricks core.repositoryFormatVersion core.bare core.ignoreStat core.safecrlf core.compression core.logAllRefUpdates core.sharedRepository core.createObject core.loosecompression core.symlinks core.deltaBaseCacheLimit core.packedGitLimit core.trustctime core.editor core.packedGitWindowSize core.warnAmbiguousRefs core.excludesfile core.pager core.whitespace core.fileMode core.preferSymlinkRefs core.worktree core.fsyncobjectfiles core.preloadindex core.gitProxy core.quotepath ~$
  • 22. prompt # Edite seu .bashrc ~$ vim ~/.bashrc # Adicionando a seguinte linha export PS1='w$(__git_ps1 "(%s)")' # Recarregue o ~/.bashrc ~$ source ~/.bashrc
  • 23. prompt # Em um repositório git ~$
  • 24. prompt # Em um repositório git ~$ cd git-tricks
  • 25. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$
  • 26. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name
  • 27. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$
  • 28. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$
  • 29. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/git-tricks(branch-name)$
  • 30. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/git-tricks(branch-name)$ echo "Olá" >> README
  • 31. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/git-tricks(branch-name)$ echo "Olá" >> README ~/git-tricks(branch-name *)$
  • 32. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/git-tricks(branch-name)$ echo "Olá" >> README ~/git-tricks(branch-name *)$ git add README
  • 33. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/git-tricks(branch-name)$ echo "Olá" >> README ~/git-tricks(branch-name *)$ git add README ~/git-tricks(branch-name +)$
  • 34. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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. prompt # Em um repositório git ~$ cd git-tricks ~/git-tricks(master)$ git checkout branch-name Switched to branch 'branch-name' ~/git-tricks(branch-name)$ export GIT_PS1_SHOWDIRTYSTATE=true ~/git-tricks(branch-name)$ ls README ~/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
  • 46. core.excludesfile .gitignore global
  • 47. core.excludesfile .gitignore global ~$ git config --global core.excludesfile ~/.gitignore ~$
  • 48. core.excludesfile .gitignore global ~$ git config --global core.excludesfile ~/.gitignore ~$ cat ~/.gitignore .DS_Store .rvmrc etc...
  • 50. help.format visualizar ajuda em HTML
  • 51. help.format visualizar ajuda em HTML ~$ git config --global help.format web
  • 52. help.format visualizar ajuda em HTML ~$ git config --global help.format web ~$ git help commit
  • 53. help.format visualizar ajuda em HTML ~$ git config --global help.format web ~$ git help commit
  • 54. help.format visualizar ajuda em HTML ~$ git config --global web.browser ff
  • 55. help.format visualizar ajuda em HTML ~$ git config --global web.browser ff ~$ git config --global browser.ff.cmd "open -a Firefox.app"
  • 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. 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
  • 59. push.default enviar apenas o branch atual
  • 60. push.default enviar apenas o branch atual ~$ git config --global push.default current
  • 62. commit.template template para a mensagem de commit
  • 63. commit.template template para a mensagem de commit ~$ cat ~/.commit-message.txt Assunto O que eu fiz [ticket: X]
  • 64. commit.template template para a mensagem de commit ~$ cat ~/.commit-message.txt Assunto O que eu fiz [ticket: X] ~$ git config --global commit.template ~/.commit-message.txt
  • 65. commit.template template para a mensagem de commit ~$ cat ~/.commit-message.txt Assunto O que eu fiz [ticket: X] ~$ git config --global commit.template ~/.commit-message.txt ~$ git commit Assunto O 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:
  • 67. help.autocorrect roda o comando correto, mesmo se você digitou errado
  • 68. help.autocorrect roda o comando correto, mesmo se você digitou errado ~$ git stat git: 'stat' is not a git command. See 'git --help'. Did you mean this? status ~$
  • 69. help.autocorrect roda o comando correto, mesmo se você digitou errado ~$ git stat git: 'stat' is not a git command. See 'git --help'. Did you mean this? status ~$ git config --global help.autocorrect 1 ~$
  • 70. help.autocorrect roda o comando correto, mesmo se você digitou errado ~$ git stat git: 'stat' is not a git command. See 'git --help'. Did you mean this? status ~$ git config --global help.autocorrect 1 ~$ git stat WARNING: You called a Git command named 'stat', which does not exist. Continuing under the assumption that you meant 'status' in 0.1 seconds automatically... # On branch master nothing to commit (working directory clean) ~$
  • 72. branch.master.rebase `git pull` no master sempre com rebase
  • 73. branch.master.rebase `git pull` no master sempre com rebase ~$ git config branch.master.rebase true # Chega de digitar `git pull --rebase`!
  • 75. branch.autosetuprebase `git pull` sempre com rebase em todos os “tracking branches”
  • 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`!
  • 79. git commit --verbose Exibe um diff abaixo da mensagem de commit
  • 80. git commit --verbose Exibe um diff abaixo da mensagem de commit ~/git-tricks(master)$ echo "Mundo" >> README ~/git-tricks(master *)$
  • 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/README index 1ca34a8..feae20b 100644 --- a/README +++ b/README @@ -1 +1,2 @@ Olá +Mundo
  • 83. git diff --word-diff diff com destaque nas palavras
  • 84. git diff --word-diff diff com destaque nas palavras ~/git-tricks(master)$ git diff diff --git a/README b/README index 84dd63e..0cc3cbe 100644 --- a/README +++ b/README @@ -1 +1 @@ -Olá Mundo +Oi Mundo ~/git-tricks(master)$
  • 85. git diff --word-diff diff com destaque nas palavras ~/git-tricks(master)$ git diff diff --git a/README b/README index 84dd63e..0cc3cbe 100644 --- a/README +++ b/README @@ -1 +1 @@ -Olá Mundo +Oi Mundo ~/git-tricks(master)$ git diff --word-diff diff --git a/README b/README index 84dd63e..0cc3cbe 100644 --- a/README +++ b/README @@ -1 +1 @@ [-Olá-]{+Oi+} Mundo
  • 87. git log --decorate Exibe branches e tags no git log
  • 88. git log --decorate Exibe branches e tags no git log ~/git-tricks(fixes)$ git log --oneline --decorate fceaeb5 (HEAD, fixes) typo c1bcf8a (tag: v0.2.0) Fix 80e9826 (origin/master, origin/HEAD, master) Second commit 3247745 (tag: v0.1.0) Initial commit ~/git-tricks(fixes)$
  • 90. git status -s -b mensagem de status curta
  • 91. git status -s -b mensagem de status curta ~/git-tricks(master)$ git status -s -b ## master...origin/master [ahead 2, behind 3] M README A TODO ?? LICENSE ?? AUTHORS ~/git-tricks(master)$
  • 93. git push -u envia um branch e configura o tracking
  • 94. git push -u envia um branch e configura o tracking ~/git-tricks(fixes)$ git push -u origin fixes * [new branch] fixes -> fixes Branch fixes set up to track remote branch fixes from origin. ~/git-tricks(fixes)$
  • 96. git checkout -t cria, faz checkout e tracking de branches remotos
  • 97. git checkout -t cria, faz checkout e tracking de branches remotos ~/git-tricks(master)$ git checkout -t origin/fixes Branch fixes set up to track remote branch fixes from origin. Switched to a new branch 'fixes' ~/git-tricks(fixes)$
  • 99. git branch visualizando informações dos branches
  • 100. git branch visualizando informações dos branches ~/git-tricks(master)$ git branch fixes i18n * master release ~/git-tricks(master)$
  • 101. git branch visualizando informações dos branches ~/git-tricks(master)$ git branch fixes i18n * master release ~/git-tricks(master)$ git branch --merged fixes * master ~/git-tricks(master)$
  • 102. git branch visualizando informações dos branches ~/git-tricks(master)$ git branch fixes i18n * master release ~/git-tricks(master)$ git branch --merged fixes * master ~/git-tricks(master)$ git branch --no-merged i18n release ~/git-tricks(master)$
  • 103. git branch visualizando informações dos branches ~/git-tricks(master)$ git branch fixes i18n * master release ~/git-tricks(master)$ git branch --merged fixes * master ~/git-tricks(master)$ git branch --no-merged i18n release ~/git-tricks(master)$ git branch --contains c1bcf8a fixes * master ~/git-tricks(master)$
  • 105. git blame -L blame com range de linhas
  • 106. git blame -L blame com range de linhas ~/rails(master)$ git blame version.rb b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 1) module Rails b1769fe0 (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 = 3 21b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1 b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0 ccd2f3ed (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) end b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 10) end ~/rails(master)$
  • 107. git blame -L blame com range de linhas ~/rails(master)$ git blame version.rb b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 1) module Rails b1769fe0 (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 = 3 21b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1 b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0 ccd2f3ed (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) end b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 10) end ~/rails(master)$ git blame -L 4,7 version.rb 21b1f297 (David Heinemeier Hansson 2010-08-23 21:44:57 -0500 4) MINOR = 1 b1769fe0 (Bryan Helmkamp 2010-03-01 23:02:55 -0500 5) TINY = 0 ccd2f3ed (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)$
  • 109. git blame -C blame com informações de onde o conteúdo veio
  • 110. git blame -C blame com informações de onde o conteúdo veio ~/rails(master)$ git blame -C -L 2,6 README.rdoc b70062f1 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)$
  • 112. stash
  • 113. stash guarda as alterações em um “commit” temporário
  • 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. 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 stash Saved working directory and index state WIP on master: 51e034d typo HEAD is now at 51e034d typo ~/git-tricks(master)$
  • 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 stash Saved working directory and index state WIP on master: 51e034d typo HEAD is now at 51e034d typo ~/git-tricks(master)$ git status -s ~/git-tricks(master)$ git stash list stash@{0}: WIP on master: 51e034d typo ~/git-tricks(master)$
  • 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 stash Saved working directory and index state WIP on master: 51e034d typo HEAD is now at 51e034d typo ~/git-tricks(master)$ git status -s ~/git-tricks(master)$ git stash list stash@{0}: WIP on master: 51e034d typo ~/git-tricks(master)$ git show stash@{0} commit 2f7289f68669d3b5e70ecff1ba7e3ac4742135e9 Merge: 51e034d 36167ac Author: Arthur Zapparoli <arthurzap@gmail.com> Date: Wed Feb 20 20:23:47 2011 -0300
  • 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. 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: mensagem HEAD is now at 51e034d typo ~/git-tricks(master)$ git stash list stash@{0}: On master: mensagem ~/git-tricks(master)$
  • 121. staging area tenho 2 arquivos, quero adicionar só 1
  • 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. 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. 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. 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. staging area quando eu quero adicionar apenas uma parte de um arquivo
  • 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. 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]elp What now>
  • 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]elp What now> 5 1: unchanged +2/-0 [A]UTHORS Patch update>> 1 * 1: unchanged +2/-0 [A]UTHORS Patch update>> diff --git a/AUTHORS b/AUTHORS index e69de29..5db9767 100644 --- a/AUTHORS +++ b/AUTHORS @@ -0,0 +1,2 @@ +Arthur +Guilherme Stage this hunk [y,n,q,a,d,/,e,?]?
  • 130. staging area quando eu quero adicionar apenas uma parte de um arquivo Stage this hunk [y,n,q,a,d,/,e,?]? y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk nor any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk nor any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help @@ -0,0 +1,2 @@ +Arthur +Guilherme Stage this hunk [y,n,q,a,d,/,e,?]?
  • 131. staging area quando eu quero adicionar apenas uma parte de um arquivo Stage 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. staging area quando eu quero adicionar apenas uma parte de um arquivo Stage 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]elp What now> 7 Bye. ~/git-tricks(master)$
  • 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. rebase
  • 135. rebase reaplica as mudanças de um branch em cima de outro
  • 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. 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. 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 authors First, 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
  • 140. reescrevendo a história editando o último commit
  • 141. reescrevendo a história editando o último commit amend
  • 142. reescrevendo a história editando o último commit ~/git-tricks(master)$ git log --oneline fceaeb5 typo c1bcf8a Fix 80e9826 Second commit 3247745 Initial commit ~/git-tricks(master)$ amend
  • 143. reescrevendo a história editando o último commit ~/git-tricks(master)$ git log --oneline fceaeb5 typo c1bcf8a Fix 80e9826 Second commit 3247745 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. reescrevendo a história editando o último commit ~/git-tricks(master)$ git log --oneline fceaeb5 typo c1bcf8a Fix 80e9826 Second commit 3247745 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 --oneline 5dc6308 typo c1bcf8a Fix 80e9826 Second commit 3247745 Initial commit ~/git-tricks(master)$ amend
  • 145. reescrevendo a história editando o último commit ~/git-tricks(master)$ git log --oneline fceaeb5 typo c1bcf8a Fix 80e9826 Second commit 3247745 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 --oneline 5dc6308 typo c1bcf8a Fix 80e9826 Second commit 3247745 Initial commit ~/git-tricks(master)$ amend
  • 147. reescrevendo a história editando vários commits de uma só vez
  • 148. reescrevendo a história editando vários commits de uma só vez rebase -i
  • 149. reescrevendo a história editando vários commits de uma só vez ~/git-tricks(master)$ git log --oneline b28e647 Fix 1e2f8a4 New Authors 76b2c02 English ~/git-tricks(master)$ rebase -i
  • 150. reescrevendo a história editando vários commits de uma só vez ~/git-tricks(master)$ git log --oneline b28e647 Fix 1e2f8a4 New Authors 76b2c02 English ~/git-tricks(master)$ git rebase -i HEAD~3 pick 76b2c02 English pick 1e2f8a4 New Authors pick 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 commit's 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. reescrevendo a história editando vários commits de uma só vez ~/git-tricks(master)$ git log --oneline b28e647 Fix 1e2f8a4 New Authors 76b2c02 English ~/git-tricks(master)$ git rebase -i HEAD~3 pick 76b2c02 English edit 1e2f8a4 New Authors pick 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 commit's 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. reescrevendo a história editando vários commits de uma só vez Stopped at 1e2f8a4... New Authors You can amend the commit now, with git commit --amend Once you are satisfied with your changes, run git rebase --continue ~/git-tricks(master|REBASE-i)$ rebase -i
  • 153. reescrevendo a história editando vários commits de uma só vez Stopped at 1e2f8a4... New Authors You can amend the commit now, with git commit --amend Once 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 --continue Successfully rebased and updated refs/heads/master. ~/git-tricks(master)$ git log --oneline edac081 Fix 0c434b4 New Authors: Arthur and Guilherme 76b2c02 English rebase -i
  • 154. reescrevendo a história editando vários commits de uma só vez Stopped at 1e2f8a4... New Authors You can amend the commit now, with git commit --amend Once 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 --continue Successfully rebased and updated refs/heads/master. ~/git-tricks(master)$ git log --oneline Antes: edac081 Fix b28e647 Fix 0c434b4 New Authors: Arthur and Guilherme 1e2f8a4 New Authors 76b2c02 English 76b2c02 English rebase -i
  • 155. reescrevendo a história reordenando commits ~/git-tricks(master)$ git log --oneline edac081 Fix 0c434b4 New Authors: Arthur and Guilherme 76b2c02 English 3933fbc Adding AUTHORS ~/git-tricks(master)$ git rebase -i HEAD~4 pick 3933fbc Adding AUTHORS pick 76b2c02 English pick 0c434b4 New Authors: Arthur and Guilherme pick edac081 Fix rebase -i
  • 156. reescrevendo a história reordenando commits ~/git-tricks(master)$ git log --oneline edac081 Fix 0c434b4 New Authors: Arthur and Guilherme 76b2c02 English 3933fbc Adding AUTHORS ~/git-tricks(master)$ git rebase -i HEAD~4 pick 76b2c02 English pick edac081 Fix pick 3933fbc Adding AUTHORS pick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  • 157. reescrevendo a história reordenando commits ~/git-tricks(master)$ git log --oneline edac081 Fix 0c434b4 New Authors: Arthur and Guilherme 76b2c02 English 3933fbc Adding AUTHORS ~/git-tricks(master)$ git rebase -i HEAD~4 pick 76b2c02 English pick edac081 Fix pick 3933fbc Adding AUTHORS pick 0c434b4 New Authors: Arthur and Guilherme ~/git-tricks(master)$ git log --oneline c3187e3 New Authors: Arthur and Guilherme 40a5b76 Adding AUTHORS 76bc060 Fix 36553c5 English ~/git-tricks(master)$ rebase -i
  • 158. reescrevendo a história deletando commits rebase -i
  • 159. reescrevendo a história deletando commits ~/git-tricks(master)$ git log --oneline c3187e3 New Authors: Arthur and Guilherme 40a5b76 Adding AUTHORS 76bc060 Fix 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~4 pick 36553c5 English pick edac081 Fix pick 3933fbc Adding AUTHORS pick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  • 160. reescrevendo a história deletando commits ~/git-tricks(master)$ git log --oneline c3187e3 New Authors: Arthur and Guilherme 40a5b76 Adding AUTHORS 76bc060 Fix 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~4 pick 36553c5 English pick 3933fbc Adding AUTHORS pick 0c434b4 New Authors: Arthur and Guilherme rebase -i
  • 161. reescrevendo a história deletando commits ~/git-tricks(master)$ git log --oneline c3187e3 New Authors: Arthur and Guilherme 40a5b76 Adding AUTHORS 76bc060 Fix 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~4 pick 36553c5 English pick 3933fbc Adding AUTHORS pick 0c434b4 New Authors: Arthur and Guilherme ~/git-tricks(master)$ git log --oneline f648606 New Authors: Arthur and Guilherme 373183d Adding AUTHORS 36553c5 English ~/git-tricks(master)$ rebase -i
  • 162. reescrevendo a história juntando commits rebase -i
  • 163. reescrevendo a história juntando commits ~/git-tricks(master)$ git log --oneline f648606 New Authors: Arthur and Guilherme 373183d Adding AUTHORS 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~3 pick 36553c5 English pick 373183d Adding AUTHORS pick f648606 New Authors: Arthur and Guilherme rebase -i
  • 164. reescrevendo a história juntando commits ~/git-tricks(master)$ git log --oneline f648606 New Authors: Arthur and Guilherme 373183d Adding AUTHORS 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~3 pick 36553c5 English pick 373183d Adding AUTHORS squash f648606 New Authors: Arthur and Guilherme rebase -i
  • 165. reescrevendo a história juntando commits ~/git-tricks(master)$ git log --oneline f648606 New Authors: Arthur and Guilherme 373183d Adding AUTHORS 36553c5 English ~/git-tricks(master)$ git rebase -i HEAD~3 pick 36553c5 English pick 373183d Adding AUTHORS squash f648606 New Authors: Arthur and Guilherme ~/git-tricks(master)$ # This is a combination of 2 commits. # The first commit's 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. reescrevendo a história juntando commits [detached HEAD 8f851b8] Adding AUTHORS 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 AUTHORS Successfully rebased and updated refs/heads/master. ~/git-tricks(master)$ git log --oneline 8f851b8 Adding AUTHORS 36553c5 English ~/git-tricks(master)$ rebase -i
  • 167. bisect ajuda a encontrar onde foram introduzidos bugs
  • 168. cherry-pick escolha quais commits fazer merge
  • 169. format-patch cria patches à partir de commits
  • 170. reflog recupera dados perdidos
  • 171. attributes define como trabalhar com arquivos binários
  • 172. rerere lembra resoluções de conflitos e as aplica automaticamente na próxima vez
  • 173. garbage collector remove objetos obsoletos
  • 174. notes adiciona notas aos seus commits
  • 175. bundles uma maneira melhor de “exportar” repositórios
  • 177. Git: do zero a samurai egenial.com.br/git