====== GIT ====== ===== Screencast ===== [[http://redmine.fireho.com/attachments/download/26/xcast-git.mov|Git ScreenCast]] **Esqueci** de agradecer umas pessoas: * Even (##ruby-br freenode.net) * Silas (Lista de rails) * De dizer a diferença entre clone/pull -> clone é só a primeira vez, para se criar a pasta do repo. Se a pasta já existe (já foi clonada), para atualizar então usa-se o pull. Desculpa galera, c eu arrumar um programa de editar vou falar de voces no final. Ou melhor ainda, falo no próximo. Abraços... pardon me... **Errata:** * Eu cito que teve um screencast do treina tom domingo. Acontece que não é screencast e não foi domingo.. => palestra, q ocorreu sábado 23/08.... treina tom. Link abaixo: * Quando digo que o git diff é parecido com o *nix diff, na verdade é o *nix diff. A grande sacada do git (e o motivo de ser complicado portar pra windows) é pq sempre que pode ele usa ferramentas já existentes. * Database I M L ñ é o instituto médico legal dos bancos de dados. Eu que viajo pra falar "iâmél" **Links do screencast:** http://git.or.cz/ http://git-scm.com/ http://www.spheredev.org/wiki/Git_for_the_lazy http://github.com http://gitorious.org/ http://www.treinatom.com.br/cafe-com-o-tom http://www.caironoleto.com/2008/08/13/diferenca-entre-git-merge-e-git-rebase/ http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way http://wiki.nofxx.com/gitar http://github.com/pragdave/codex/tree/master Git em português => [[gitar]] ====== Iniciando ====== git config --global user.name "Santos Dumont" git config --global user.email pai.do@opensource.com # colors git config --global color.diff auto git config --global color.status auto git config --global color.branch auto git config --global color.interactive auto # shortcuts git config --global alias.st status git config --global alias.ci commit git config --global alias.co checkout git config --global alias.br branch ===== Mac ===== # opendiff pra conflitos git config --global merge.tool opendiff # sumario no merge git config --global merge.summary true # fonte decente no gitk cat >~/.gitk <<\EOF set mainfont {Monaco 12} set textfont {Monaco 12} set uifont {Monaco 12} EOF http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/ ====== Mostrar Branch No Prompt ====== No seu ~/.bashrc parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } PS1='\[\e[0;32m\]\u::\h\[\e[m\] \[\e[1;37m\]\w\[\e[m\] $(parse_git_branch) \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] ' ====== Comandos ====== ===== Criando um repo ===== mkdir xrepo cd xrepo/ git init ===== Trampando ===== git clone repo git branch xx git checkout xx git coffee git add .... git commit -a -m "bla" git checkout master git merge xx git push [...] git pull git show (master|branch|...) ==== Add ==== git add . git add -i git gui git commit -a ==== Branch! ==== git checkout -b nova git branch git branch -D apaga ==== Merge ==== git-merge(1) to merge between local branches. git-rebase(1) to maintain topic branches. ==== Mudanças ==== git status git log git diff git diff rev path git-whatchanged -p ==== Revert and Patches ==== git diff master > my.patch patch < hacking.patch git apply (patch -p0) git-reset(1) and git-checkout(1) (with pathname parameters) to undo changes. git-format-patch(1) to prepare e-mail submission, if you adopt Linux kernel-style public forum workflow. ==== Utils ==== git-tag(1) to mark known point. git tag -s tag com comentario e pgp git-fsck git count-objects git-gc ===== Remoto ====== git clone --bare Projeto/.git projeto.git scp -r projeto.git user@server:/var/repo/x Ou, server: $ mkdir /var/git/myapp.git && cd /var/git/myapp.git $ git --bare init Cliente: $ cd ~/Sites/myapp $ git remote add origin ssh://myserver.com/var/git/myapp.git $ git push origin master ===== Hacks ===== .git/config [branch "master"] remote = origin merge = refs/heads/master ==== hack sink ship ==== http://gist.github.com/8511 Pra .bashrc # hack hack(){ git checkout master git pull origin master git checkout -b $1 master } # sink sink(){ CURRENT=`git branch | grep "*" | awk '{print $2}'` git checkout master git pull origin master git checkout ${CURRENT} git rebase master ${CURRENT} } # ship ship(){ CURRENT=`git branch | grep "*" | awk '{print $2}'` git checkout master git merge --squash ${CURRENT} && git commit -a -v && git push origin master } ===== GIT SVN ===== git svn clone svn:repo Soh ultima versao (HEAD): git-svn -r HEAD clone svn:repo Now we are on git! git checkout -b xx git commit.... git checkout master git svn rebase git checkout xx git merge master ===== .bashrc ===== parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } PS1='\[\e[0;32m\]\h\[\e[m\] \[\e[1;36m\]\w $(parse_git_branch)\[\e[m\] \[\e[m\] \[\e[1;32m\]\$ \e[m\]' ===== Ignore ====== .gitignore test_log pkg pkg/* *.log log !log*.rb */log log/* */log/* coverage .DS_Store thumbs.db tmp tmp/* Rails: .gitignore ====== Sashimi ====== sashimi install foo-repo sashimi add foo ====== Links ====== lost a bunch http://pluskid.lifegoo.com/?p=295 http://drnicwilliams.com/2008/02/03/using-git-within-a-team/