name: portada class: portada-slide, middle, right # Git Basics ## __UD2:__ Introducció a Git .footnote[Joan Puigcerver Ibáñez ([j.puigcerveribanez@edu.gva.es](mailto:j.puigcerveribanez@edu.gva.es))] --- layout: true class: regular-slide .right[.logo[]] --- # Què és Git? Git és __un sistema de control de versions lliure i distribuït__ dissenyat per gestionar xicotets i grans projectes amb rapidesa i eficència. .center[https://git-scm.com/] Git està basa en __repositoris__. Aquestos repositoris poden contindre carpetes i fitxers, però a més, també es fa un seguiment dels canvis que s'han realitzat en les dades. --- # Git vs GitHub __Git__ és el sistema de control de versions. __GitHub__ o __GitLab__ són un servei d'allotjament de repositoris de Git. .img-50[] .center[https://github.com/] .img-50[] .center[https://gitlab.com/] --- # Components  --- # Fork  --- # Autenticació - __Personal Acces Token__: - Generar el token a GitHub ```bash git clone https://
@github.com/
/
.git ``` - __SSH__: - Generar el parell de claus en el teu dispositiu - Configurar la clau pública en GitHub ```bash git clone git@github.com:
/
.git ``` --- # Clone ```bash git clone
```  --- # Add ```bash git add
```  --- # Commit ```bash git commit -m
```  --- # Push ```bash git push ```  --- # After Push  --- # Diff ```bash git diff ``` ```diff diff --git a/Bob.txt b/Bob.txt index 8eb57c4..3ed0e1b 100644 --- a/Bob.txt +++ b/Bob.txt @@ -1 +1 @@ -Hi!! I'm Bob. I'm new here. +Hi! I'm Bob. I'm new here. ``` --- # Diff ```bash git diff git diff --staged ```  --- # Log ```diff commit 87a4ad48d55e5280aa608cd79e8bce5e13f318dc (HEAD -> master) Author: {YOU} <{YOUR EMAIL}> Date: Sun Jan 27 14:02:48 2019 +0100 Add text to Bob commit 8af2ff2a8f7c51e2e52402ecb7332aec39ed540e (origin/master, origin/HEAD) Author: {YOU} <{YOUR EMAIL}> Date: Sun Jan 27 13:35:41 2019 +0100 Add Bob commit 71a6a9b299b21e68f9b0c61247379432a0b6007c Author: UnseenWizzard
Date: Fri Jan 25 20:06:57 2019 +0100 Add Alice commit ddb869a0c154f6798f0caae567074aecdfa58c46 Author: Nico Riedmann
Date: Fri Jan 25 19:25:23 2019 +0100 Add Tutorial Text Changes to the tutorial are all squashed into this commit on master, to keep the log free of clutter that distracts from the tutorial See the tutorial_wip branch for the actual commit history ``` --- # Log options & alias - Fitxer: __~/.gitconfig__ ``` [user] name =
email =
[alias] lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all lg = !"git lg1" ```