Curso de Introducción a Git y GitHub
Héctor Nieto Solana
[email protected] Programa
DÍA 1
●
Importancia del versionado y documentación de software
[teoría]
●
Qué es Git y la plataforma GitHub [teoría]
●
Primeros pasos en Git y GitHub, [práctica]
– Instalación de Git
– Configuración de Git, archivos básicos
DIA 3
●
Fusionado y resolución de conflictos [práctica]
DÍA 2
– Fusionado de ramificaciones
●
Iniciación a Git [práctica]
– Crear repositorios
– Resolución de conflictos
– Control de cambios y versionado ●
Código colaborativo en GitHub [práctica]
– Restaurar versiones previas ("checkout" y "restore") – Creación de copias ("forks")
– Ramificaciones ("branches") del código – Sugerencias de cambios ("Pull requests")
– Actualizar el repositorio local y remoto
Qué es Git?
GIT - the stupid content tracker
●
"git" can mean anything, depending on your mood.
– random three-letter combination that is pronounceable, and not actually used by any
common UNIX command. The fact that it is a mispronounciation of "get" may or may
not be relevant.
– stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
– “Global Information Tracker": you're in a good mood, and it actually works for you.
Angels sing, and a light suddenly fills the room.
– "Goddamn Idiotic Truckload of sh*t": when it breaks
https://github.com/git/git/blob/master/README.md
Qué es Git
●
'git' is British slang for "pig
headed, think they are always
correct, argumentative".
●
Linus Torvalds: "I'm an
egotistical bastard, and I name
all my projects after myself.
First 'Linux', now 'Git'".
https://git.wiki.kernel.org/index.php/GitFaq#Why_the_.27Git.27_name.3F
Por qué Git
●
Sistema de versionado y control de contenidos
– Código
– Datos
– Texto
●
Características
– Rápido
– Diseño sencillo
– Desarrollo no lineal - en ramas paralelas
– Totalmente distribuido
– Capaz de manejar grandes proyectos eficientemente (núcleo “kernel” de Linux)
Por qué Git
●
Sistema de versionado y control de contenidos
– Código
– Datos
–
FUNDAMENTAL DOCUMENTAR
Texto
Características
CÓDIGO Y SUS CAMBIOS
●
– Rápido
– Diseño sencillo
– Desarrollo no lineal - en ramas paralelas
– Totalmente distribuido
– Capaz de manejar grandes proyectos eficientemente (núcleo “kernel” de Linux)
Cómo funciona Git
Chacon & Straub (2021) Pro Git
●
– Con ánimo de lucro
●
Ayuda:
– Trabajo colaborativo
– Diseminación de código abierto
– Herramientas para la difusión
Git y GitHub
●
Puedes usar sin problema Git sin necesidad de
GitHub
●
Si usas GitHub es recomendable conocer Git
●
Alternativas a GitHub
– GitLab, Bitbucket
– … servidor propio
Add-ons de GitHub
●
Generación de DOIs
– https://zenodo.org/
– https://guides.github.com/activities/citable-code/
●
Documentación de software online
– https://readthedocs.org/
– https://github.com/readthedocs/readthedocs.org
●
Servicio de páginas web
– https://pages.github.com/
Documentación y legibilidad
“Code is more often read than written” (Guido van Rossum)
Máximo 80 caracteres por línea
●
Python
– Guía de estilo del código: https://www.python.org/dev/peps/pep-0008/
– Guía de estilo de Numpy docstrings:https://numpydoc.readthedocs.io/en/latest/format.html
●
R
– Roxygen2 docstrings: https://github.com/r-lib/roxygen2
●
C
– Guía de estilos para Python: https://www.python.org/dev/peps/pep-0007/
Primeros Pasos: versionado
init
C0 C1 Cn
clone
add commit add commit
STAGED
AREA Archivos Archivos
modificados modificados
Primeros Pasos: repositorio local y
remoto
local
Cn
C0 C1 C2 C3 C4
HEAD
push fetch / pull
GitHub
Cn
C0 C1 C2 C3 C4
HEAD
Primeros Pasos: control de cambios
Primeros Pasos: restaurado
Cn
C0 C1 C2 C3 C4
HEAD
checkout
Archivos
Commit 3
Primeros Pasos: restaurado
Cnn
C0 C1 C2 C3 C4
HEAD
restore
Archivos
Commit 3
Cn+1
HEAD
Primeros Pasos: ramas
main
C0 C1 C2 C3 C4 C0
C5 C6 C8
C7
HEAD
branch
C21 C22 C
C0
2
3 C24 dev
branch
C31 C32 C
C0
3
3
Fusionado: rebase
main
C0 C1 C2 C3 C4 C5
C0 C6 C8
C7
HEAD
C21 C22 C
C0
2
3 C24 dev
Fusionado: rebase
main
C0 C1 C2 C3 C4 C5
C0 C6 C8
C7
HEAD
rebase
C21 C22 C
C0
2
3 C24 dev
Fusionado: merge
main
C0 C1 C2 C3 C4 C5
C0 C6 C8
C7
HEAD
C2 1 C22 C
C0
2
3 C24
dev
Fusionado: merge
main
C0 C1 C2 C3 C4 C5
C0 C6 C8
C7
merge C24
C21 C22 C
C03
2
HEAD
C2 1 C22 C
C0
2
3 C24
dev
Fusionado: resolución de conflictos
main
C0 C1 C2 C3 C4 C5
C0 C6 C8
C7
HEAD
C3:
...
C2: spam egg spam egg and spam
... …
spam eggs bacon and spam
... C21:
...
spam spam spam egg and spam
...
C21 C22 C
C02
3 C24
dev
Fusionado: resolución de conflictos
egg and bacon
egg sausage and bacon
egg and spam
egg bacon and spam
egg bacon sausage and spam
spam bacon sausage and spam
spam egg spam spam spam bacon and spam
>>>>>>>>HEAD
spam egg spam egg and spam
========
spam spam spam egg and spam
<<<<<<<<C21
spam spam spam spam spam spam baked beans spam spam spam spam and spam
lobster termidor aux crevettes with a mornay sauce garnished with truffle pate, brandy and a fried egg on top and spam
Fusionado: resolución de conflictos
egg and bacon
egg sausage and bacon
egg and spam
egg bacon and spam
egg bacon sausage and spam
spam bacon sausage and spam
spam egg spam spam spam bacon and spam
spam spam spam egg and spam
spam spam spam spam spam spam baked beans spam spam spam spam and spam
lobster termidor aux crevettes with a mornay sauce garnished with truffle pate, brandy and a fried egg on top and spam
add commit continue
Código colaborativo
Código colaborativo
Código colaborativo