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

Workshop Git para o DevInSanta meetup.

Workshop Git para o DevInSanta meetup.

Git para iniciantes.

Nando Sousa

October 21, 2014
Tweet

More Decks by Nando Sousa

Other Decks in Technology

Transcript

  1. O que é git? • Sistema de Controle de Versão

    ou SCM (Source Control Management) • Ferramenta colaborativa para desenvolvimento de software • O SCM mais utilizado atualmente • Conhecimento essencial para qualquer desenvolvedor
  2. SCM Centralizado $ ls -1 README.md app/ config/ doc/ db/

    $ ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/
  3. SCM Distribuído $ ls -1 README.md app/ config/ doc/ db/

    $ ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/
  4. Timeline Adicionado README Moyses Santos 021e1bfeec7834a5a9d4b251c2d702 Adicionado seção de licença

    no README Nando Sousa ebd65019fe3e917310dfffe5f4237309 Corrigida seção de licença no README Francisco Olivar 021e1bfeec7834a5a9d4b251c2d702
  5. Configurando $ git config --global user.name "Nando Sousa" $ git

    config --global user.email "[email protected]" $ git config --global color.ui true
  6. Criando um repositório $ mkdir devinsanta $ cd devinsanta $

    git init Initialized empty Git repository in /home/nandosousa/devinsanta/.git/
  7. git status $ git status On branch master Initial commit

    nothing to commit (create/copy files and use “git add” to track)
  8. git add $ touch README.md $ git status Initial commit

    Untracked files: (use "git add <file>.." to include in what will be committed) README.md nothing added to commit but untracked files present (use "git add" to track)
  9. git add $ git add README.md $ git status Changes

    to be committed: (use "git rm --cached <file>..." to unstage) new file: README.md
  10. $ git add arquivoA arquivoB arquivoC Maneiras de usar o

    git add $ git add --all $ git add *.txt $ git add docs/*.txt $ git add docs $ git add "*.txt"
  11. git commit $ git commit -m 'adicionado README.md' [master (root-commit)

    40e292e] adicionado README.md 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 README.md
  12. Workflow $ ls -1 README.md app/ config/ doc/ db/ $

    ls -1 README.md app/ config/ doc/ db/ $ ls -1 README.md app/ config/ doc/ db/ push pull pull $ ls -1 README.md app/ config/ doc/ db/ github
  13. git remote add <name> <url> $ git remote add origin

    https://github.com/nandosousafr/devinsanta.git $ git push origin master Username for 'https://github.com': [email protected] Password for 'https://[email protected]@github.com': Counting objects: 3, done. Writing objects: 100% (3/3), 223 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/nandosousafr/devinsanta.git * [new branch] master -> master
  14. git remote $ git remote rm <name> $ git remote

    show $ git remote show <name> Lista todos os remotes Remove um remote Mostra informações de um remote
  15. git remote $ git remote show origin * remote origin

    Fetch URL: https://github.com/nandosousafr/devinsanta.git Push URL: https://github.com/nandosousafr/devinsanta.git HEAD branch: master Remote branch: master tracked Local ref configured for 'git push': master pushes to master (up to date)