jesus@jesusamieiro · git add . git commit -m "commit inicial. engado o index.html e o...

89

Upload: others

Post on 21-Aug-2020

43 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore
Page 2: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore
Page 4: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore
Page 5: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

● Introdución● Instalación● Configuración● Conceptos básicos ● Exercicio

● Comandos básicos● Ramas ● Repositorios remotos

Contido

Page 6: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Que é?

Page 7: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Orzamento_v2.doc

Page 8: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

factura_final_2.ods

Cartel_v5.jpg

Page 9: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

2010_05_17_web

Page 10: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Problemas

Page 11: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore
Page 12: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore
Page 13: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

VCS: Version Control System

SCM: Source Control Management

Page 14: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Commit

Page 15: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Para quen?● Linguaxes interpretados● Linguaxes compilados● Deseñadores● PDF, docx, odt,...

Page 16: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Tipos de SCM

Page 17: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

LocaisSCCS RCS 1972 1982

Page 18: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Versión 1

tiempo

Versión 1

Versión 2

Versión 1

Versión 2

Versión 3

Versión 1

Versión 2

Versión 3

Versión 4Equipo local

Page 19: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Cliente servidorCVS Subversion

1990 2000

Page 20: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Versión 1

Versión 2

Versión 3Equipo 1

Equipo 2

Equipo 3

Equipo 4

Servidorcentral

Page 21: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Distribuidos

Page 22: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Equipo 1

V 1

V 2

V 3

Equipo 2

V 1

V 2

V 3

Equipo 3

V 1

V 2

V 3

Servidor

V 1

V 2

V 3

Page 23: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

A creación de Git

Page 24: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

BitKeeper2000

Page 25: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

● Rápido e escalable● Copia completa● Desenvolvemento distribuído● Traballo local● Alenta as ramas● Instantáneas

Git. Características

Page 26: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

● Múltiples protocolos● Robustez: SHA-1● Libre ● Gratuito

Git. Características (II)

Page 27: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Versións

Page 28: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Windows Git for Windows

Page 29: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

apt-get install git

Page 30: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

yum install git

Page 31: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

MacGit-osx-installer

MacPorts

Page 32: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Obter axuda

Page 33: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git help [comando]git help init

git [comando] --help git init --help

Page 34: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

man git-[comando]man git-init

man git [comando]man git init

Page 35: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Subcomandosgit help -a

Guías de conceptosgit help -g

git help [concepto]git help glossary

Page 36: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración inicial de Git

Page 37: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

● Sistema● /etc/gitconfig● C:\Program Files (x86)\Git\etc\gitconfig

● git config --system

Page 38: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

● Usuario● ~/.gitconfig● C:\Users\Mi usuario\.gitconfig

● git config --global

Page 39: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

● Repositorio● .git/config

● git config --local

Page 40: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

git config --global user.name "Jesús Amieiro"

git config --global user.email “[email protected]

Page 41: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

git config --global core.editor emacs

git config --global core.editor vim

git config --global core.editor notepad.exe

Page 42: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

git config --global merge.tool vimdif

git config --global color.ui true

git config --global core.autocrlf true

git config --global core.autocrlf input

Page 43: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Configuración

git config --global user.name

git config --global user.email

git config --list

Page 44: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Conceptos básicos

Page 45: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Repositorio

Page 46: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Commit

Page 47: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Zonas en GitDirectoriode trabajo

Zona de preparación Repositorio

Preparar archivos

Commit

Checkout

Page 48: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Estados e fluxo

Ignorado

Con seguimientoSin

seguimientoSin

modificación Modificado

Añadir archivo

Edición

Commit

Preparado

Eliminar archivo

Page 49: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

SHA-1

Commit 160 bitsFunciónSHA-1

Page 50: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

HEAD75528b9

Commit 1

75528b9

Commit 1

8daf16a

Commit 2

75528b9

Commit 1

8daf16a

Commit 2

a346348

Commit 3

Page 51: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

EXERCICIO

Page 52: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

● Desde repositorio remoto: git clonecd ~

git clone [email protected]:twbs/bootstrap.git

git clone https://github.com/twbs/bootstrap.git

ls bootstrap

ls -la bootstrap

Inicialización

Page 53: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

● Local: git initmkdir ~/exemplo

cd ~/exemplo

git status

ls -la

git init

ls

ls -la

Inicialización (II)

Page 54: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

ls -la .git

cat .git/config

git status

Inicialización (III)

Page 55: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

touch primeiro_arquivo.txt

ls

git status

git add primeiro_arquivo.txt

# Alternativa: git add .

git status

git commit -m "Engado o primeiro arquivo baleiro"

git status

Xestión arquivos

Page 56: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

touch segundo_arquivo.txt

touch terceiro_arquivo.txt

git status

git add segundo_arquivo.txt

git status

git commit -m "Engado o segundo arquivo"

git status

git add terceiro_arquivo.txt

Xestión arquivos (II)

Page 57: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git status

git commit -m "Engado o terceiro arquivo"

git status

git log

git log --oneline

Xestión arquivos (III)

Page 58: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

echo "Creo unha primeira liña no primeiro arquivo" >> primeiro_arquivo.txt

git status

git add primeiro_arquivo.txt

git status

echo "Creo unha primeira liña no segundo arquivo." >> segundo_arquivo.txt

echo "Creo unha primeira liña no terceiro arquivo." >> terceiro_arquivo.txt

Edición arquivos

Page 59: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git status

git add segundo_arquivo.txt

git status

git commit -m "Introduzo unha liña no primeiro e no segundo arquivo"

git status

git log

git log --oneline

git add terceiro_arquivo.txt

Edición arquivos (II)

Page 60: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git commit -m "Introduzo unha liña no terceiro arquivo"

git status

Edición arquivos (III)

Page 61: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

echo "Creo unha segunda liña no primeiro arquivo" >> primeiro_arquivo.txt

cat primeiro_arquivo.txt

git status

git dif

echo "Creo unha segunda liña no segundo arquivo" >> segundo_arquivo.txt

cat segundo_arquivo.txt

Ver cambios

Page 62: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git status

git dif

git dif segundo_arquivo.txt

Ver cambios (II)

Page 63: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git add segundo_arquivo.txt

git status

git dif

git dif --staged

git dif --cached

git dif HEAD

git add primeiro_arquivo.txt

git status

Ver cambios (III)

Page 64: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git dif

git dif HEAD

git dif --staged

git commit -m "Engado liñas no primeiro e no segundo arquivo"

git status

git dif

git dif HEAD

git dif --staged

Ver cambios (IV)

Page 65: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git dif $SHA_1..$SHA2

git dif $SHA_1..$SHA2 – segundo_arquivo.txt

Ver cambios (V)

Page 66: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Zona de traballo

git status

echo "Engado unha terceira liña ao primeiro arquivo" >> primeiro_arquivo.txt

cat primeiro_arquivo.txt

git status

git dif

git checkout -- primeiro_arquivo.txt

cat primeiro_arquivo.txt

git status

Desfacer cambios

Page 67: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Índice

git status

echo "Engado unha terceira liña ao primeiro arquivo" >> primeiro_arquivo.txt

cat primeiro_arquivo.txt

git status

git add primeiro_arquivo.txt

git status

git reset HEAD primeiro_arquivo.txt

git status

cat primeiro_arquivo.txt

Desfacer cambios (II)

Page 68: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git log --oneline

cat primeiro_arquivo.txt

git checkout $SHA_commit primeiro_arquivo.txt

# Dous commit antes

cat primeiro_arquivo.txt

git dif --staged

git checkout -- primeiro_arquivo.txt

# git checkout HEAD primeiro_arquivo.txt

git status

Desfacer cambios (III)

Page 69: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

touch arquivo_temporal.txt

git status

touch .gitignore

git status

echo "arquivo_temporal.txt" >> .gitignore

git status

mkdir log

touch log/untrack01.log

mkdir images

Ignorar archivos

Page 70: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

touch images/untrack01.jpg

echo "*.zip" >> .gitignore

echo "*.gz" >> .gitignore

echo "log/*.log" >> .gitignore

echo "log/*.log[0-9]" >> .gitignore

echo "images/" >> .gitignore

echo "! images/logo.png" >> .gitignore

git status

git add .gitignore

Ignorar archivos (II)

Page 71: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git commit -m "Engado o arquivo .gitignore"

git status

git log --oneline

https://github.com/github/gitignore

Ignorar archivos (III)

Page 72: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Se existe o arquivo

git rm arquivo_temporal.txt # Borro o arquivo

git rm --cached arquivo_temporal.txt

Ignorar archivos (IV)

Page 73: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Ramas

75528b9

Commit 1

8daf16a

Commit 2

de396a3

Commit 5

a3ae45c

Commit 3

456af81

Commit 4

pruebas

master

HEAD

Page 74: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Crear unha rama

git branch

ls -la .git

cat .git/HEAD

ls -la .git/refs/heads/

cat .git/refs/heads/master

git log -1

git branch desenvolvemento

Ramas (II)

Page 75: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git branch

ls -la .git/refs/heads/

cat .git/refs/heads/master

cat .git/refs/heads/desenvolvemento

Ramas (III)

Page 76: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Cambio de rama

git branch

cat .git/HEAD

git checkout desenvolvemento

cat .git/HEAD

# Crear unha rama e cambiarse a ela

git checkout -b experimento

Ramas (IV)

Page 77: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Traballo na nova rama

echo "Inserto unha liña no primeiro arquivo" >> primeiro_arquivo.txt

git status

git commit -am "Introduzo unha nova liña no primeiro_arquivo.txt da rama de desenvolvemento"

git log --oneline -5

git checkout master

git log --oneline -5

Ramas (V)

Page 78: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

cat primeiro_arquivo.txt

git checkout desenvolvemento

cat primeiro_arquivo.txt

git log --oneline -5

cat .git/HEAD

git show HEAD

Ramas (VI)

Page 79: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Fusión

git log --oneline -6 --graph --all --decorate

git checkout master

git merge desenvolvemento

# Problemas de fusión

Ramas (VII)

Page 80: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Usuario 1

# Creo e comparto o repositorio remoto en Bitbucket

mkdir -p ~/usuario1/git_universidade

cd ~/usuario1/git_universidade/

git init

touch index.html

echo "Simulación do arquivo index.html" >> index.html

touch style.css

Repositorios remotos

Page 81: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

echo "Simulación do arquivo style.css" >> style.css

git add .

git commit -m "Commit inicial. Engado o index.html e o style.css"

git tag -a v0.0.1 -m "Commit inicial"

git checkout -b dev

touch todo.txt

touch .gitignore

echo "todo.txt" >> .gitignore

Repositorios remotos (II)

Page 82: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git add .gitignore

git commit -m "Engado o arquivo .gitignore"

git remote add origin https://[email protected]/amieiro/git_universidade.git

#Tamén git remote add origin [email protected]:amieiro/git_universidade.git).

git push -u origin master

git push -u origin dev

git push --tags

Repositorios remotos (III)

Page 83: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Usuario 2

mkdir ~/usuario2 && cd ~/usuario2

git clone https://[email protected]/amieiro/git_universidade.git

cd git_universidade/

git branch -a -v

git checkout -b dev origin/dev

mkdir img

Repositorios remotos (IV)

Page 84: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

cd img/

touch logo.png

touch logo.xcf

cd ..

echo "img/*.png" >> .gitignore

git status

git add .gitignore

git add img/logo.xcf

Repositorios remotos (V)

Page 85: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

git status

git commit -m "Engado o logo e modifico o .gitignore"

git checkout master

git merge dev

git push --all

Repositorios remotos (VI)

Page 86: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

# Usuario 1

git checkout master

git pull --all

git branch -a -v

git checkout dev

git pull

git branch -a -v

mkdir js/

Repositorios remotos (VII)

Page 87: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

cd js/

touch jquery-2.1.0.min.js

cd ..

git add .

git commit -m "Añado el archivo jquery-2.1.0.min.js"

git checkout master

git merge dev

git push --all

Repositorios remotos (VIII)

Page 88: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

Onde continuar?Libro “Pro Git” https://progit.org

Libro “Version Control with Git” de O'Really

Git Cheatsheets

Page 89: jesus@jesusamieiro · git add . git commit -m "Commit inicial. Engado o index.html e o style.css" git tag -a v0.0.1 -m "Commit inicial" git checkout -b dev touch todo.txt touch .gitignore

www.jesusamieiro.com