Git & Github

usa logo, pow!


gjuniioor

Quem é esse menino do computador?

Git

O que é?

Qual necessidade??

  • Histórico de código

O que é?

Qual necessidade??

Instalação

  • Linux:
    $ pacman -S git
    $ apt-get install git
    $ yum install git
  • Git Downloads

Primeiros Passos

git config

$ git config --global user.name "moreninho22"
$ git config --global user.email "moreninho22@bol.com.br"
$ git config --list
user.email=moreninho22@bol.com.br
user.name=moreninho22

git init

$ git init
Initialized empty Git repository in ~/test/.git/

Os espaços do Git

  • Working directory
  • Index
  • HEAD

git status

$ git status
On branch master
        
Initial commit
        
nothing to commit (create/copy files and use "git add" to track)

git add

$ git add .

git commit

$ git commit -m "Descrição desse commit"
[master (root-commit) cdd55e2] Descrição desse commit
1 file changed, 1 insertion(+)
create mode 100644 index.html

Gostou, né?! Bora ver mais!!


fonte

git log

$ git log
commit cdd55e290575ea3679352ee44ac9879d866297a5
Author: moreninho22 <moreninho22@bol.com.br>
Date:   Tue Mar 1 10:56:22 2016 -0300

Descrição desse commit

git show

$ git show cdd55e290575ea3679352ee44ac9879d866297a5
commit cdd55e290575ea3679352ee44ac9879d866297a5
Author: moreninho22 <moreninho22@bol.com.br>
Date:   Tue Mar 1 10:56:22 2016 -0300

Descrição desse commit

diff --git a/index.html b/index.html
new file mode 100644
index 0000000..c09fc3c
--- /dev/null
+++ b/index.html
@@ -0,0 +1 @@
+oi

git diff (--staged)

$ git diff
diff --git a/index.html b/index.html
index c09fc3c..e303df0 100644
--- a/index.html
+++ b/index.html
@@ -1 +1 @@
-oi
+Oi, amiguinho

git mv

$ git mv index.html hello.html

git rm

$ git rm file

git reset

$ git reset hello.html

Github

O que é?

Qual necessidade?

Alguns clicks ...

  • Criar conta
  • Apresentação da interface
  • Criar repositórios
  • Organizações

git clone

$ git clone https://github.com/lampiaosec/virada-hacker
Cloning into 'virada-hacker'...
remote: Counting objects: 216, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 216 (delta 3), reused 0 (delta 0), pack-reused 199
Receiving objects: 100% (216/216), 15.57 MiB | 411.00 KiB/s, done.
Resolving deltas: 100% (44/44), done.
Checking connectivity... done.

git remote

$ git remote add origin https://github.com/gjuniioor/testeando

git push

$ git push -u origin master

git pull

$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/gjuniioor/testeando
cdd55e2..7defde2  master     -> origin/master
Updating cdd55e2..7defde2
Fast-forward
README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 README.md

Branchs

O que são?

Pra que serve?

git branch (-a)

$ git branch novo_branch

git checkout (-b)

$ git checkout novo_branch

git push

$ git push origin novo_branch
Username for 'https://github.com': gjuniioor
Password for 'https://gjuniioor@github.com':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 332 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/gjuniioor/testeando
* [new branch]      novo_branch -> novo_branch

Issues

Pull Requests

git merge

$ git merge novo_branch
$ git commit -m "Closes #1"
[master 8eeca72] Closes #1
1 file changed, 1 deletion(-)
delete mode 100644 index.html
$ git push

Remover branchs

$ git branch -d novo_branch
Deleted branch novo_branch (was 4ed54fe).
$ git push origin :novo_branch
Username for 'https://github.com': gjuniioor
Password for 'https://gjuniioor@github.com':
To https://github.com/gjuniioor/testeando
- [deleted]         novo_branch

Outras funcionalidades massa!

  • Wiki
  • Label
  • Milestone
  • Gráficos
  • Github Pages

Onde aprender mais?

Dúvidas??

gjuniioor