Loading...git

44

Transcript of Loading...git

Page 1: Loading...git
Page 2: Loading...git

whoami

Rafa García

Web developerAdministrador de Sistemas

Entusiasta del software libre

Page 3: Loading...git

¡Encuesta rápida!

● ¿Quién NO está usando un SCM?

Page 4: Loading...git

¡Encuesta rápida!

● ¿Quién NO está usando un SCM?● ¿Subversion?

Page 5: Loading...git

¡Encuesta rápida!

● ¿Quién NO está usando un SCM?● ¿Subversion?● ¿CVS? (¿todavía?)

Page 6: Loading...git

¡Encuesta rápida!

● ¿Quién NO está usando un SCM?● ¿Subversion?● ¿CVS? (¿todavía?)

Page 7: Loading...git

C'est la vie

Le Voyage Magnifique es obra de Debra Chow - http://vimeo.com/6846068

Page 8: Loading...git

¿Qué es Git?

Page 9: Loading...git

¿Qué es Git?

Git sistema de control de versiones distribuido, open source,

diseñado para ser rápido y eficiente.

Page 10: Loading...git

¿Por qué Git?

● Distribuido● ¡Es muy rápido!● Branching● Workflows● Una gran comunidad detrás

Page 11: Loading...git

Configurar Git

By Twicepix - http://www.flickr.com/photos/twicepix/4288056667/

Page 12: Loading...git

Configurar Git

$ git config --global user.name "Rafa G."

$ git config --global user.email "[email protected]"

# Extraball

$ git config --global color.ui auto

$ git config --global core.editor /usr/bin/vim

Page 13: Loading...git

Crear repositorio

$ mkdir foo

$ cd foo/

~/foo$ git init

Initialized empty Git repository in ~/foo/.git/

Page 14: Loading...git

Trabajando con Git

Page 15: Loading...git

Estado del repositorio

$ git status

# On branch master

#

# Initial commit

#

nothing to commit (create/copy files and use "git add" to track)

Page 16: Loading...git

Estado del repositorio

$ touch README

$ git status

# On branch master

#

# Initial commit

#

# Untracked files:

# (use "git add <file>..." to include in what will be committed)

#

# README

nothing added to commit but untracked files present (use "git add" to track)

Page 17: Loading...git

Stage

$ git add README

Page 18: Loading...git

Stage

$ git add README

$ git status

# On branch master

#

# Initial commit

#

# Changes to be committed:

# (use "git rm --cached <file>..." to unstage)

#

# new file: README

#

Page 19: Loading...git

Commit

$ git commit -m 'First commit. Adelante caminante!'

[master (root-commit) e3e4e54] First commit. Adelante caminante!

0 files changed, 0 insertions(+), 0 deletions(-)

create mode 100644 README

Page 20: Loading...git

Ignorar ficheros

$ cat .gitignore

.bundle/

db/sphinx/*

log/**/*

log/*

tmp/**/*

tmp/*

.rvmrc

Page 21: Loading...git

Deshaciendo cambios

By Gaelx - http://www.flickr.com/photos/gaelx/2664672458/

Page 22: Loading...git

Deshaciendo cambios

$ echo "Loadin$%&... Git" > README

$ git status

# On branch master

# Changed but not updated:

# (use "git add <file>..." to update what will be committed)

# (use "git checkout -- <file>..." to discard changes in working directory)

#

# modified: README

#

no changes added to commit (use "git add" and/or "git commit -a")

$ git checkout README

$ git status

# On branch master

nothing to commit (working directory clean)

Page 23: Loading...git

Deshaciendo cambios

$ echo "A not useful text" > README

$ git add .

$ git status

# On branch master

# Changes to be committed:

# (use "git reset HEAD <file>..." to unstage)

#

# modified: README

#

$ git reset HEAD README

Page 24: Loading...git

Deshaciendo cambios

$ echo "Yeeeeeeeha" > README

$ git add .

$ git commit -m 'Upss this is FAIL'

$ git revert HEAD

Finished one revert.

[detached HEAD 19c6cb5] Revert "Upss this is FAIL"

1 files changed, 1 insertions(+), 1 deletions(-)

Page 25: Loading...git

Deshaciendo cambios

By Stan Lee

Page 26: Loading...git

Deshaciendo cambios

$ git reset --hard HEAD^^^

# Que es lo mismo que...

$ git reset --hard HEAD~3

Page 27: Loading...git

Deshaciendo cambios

$ git reset --hard HEAD^^^

# Que es lo mismo que...

$ git reset --hard HEAD~3

# O una versión mas light

$ git reset --soft HEAD^

Page 28: Loading...git

Branch

By n8agrin - http://www.flickr.com/photos/n8agrin/2735063012/

Page 29: Loading...git

Branch

# Creamos la rama

$ git branch loading

$ git checkout loading

Switched to branch 'loading'

# Extraball

$ git checkout -b loading

Switched to a new branch 'loading'

Page 30: Loading...git

Branch

# Moverse por las ramas

$ git branch loading

$ git branch riojaparty

$ git checkout loading

Switched to branch 'loading'

$ git checkout riojaparty

Switched to branch 'riojaparty'

$ git checkout master

Switched to branch 'master'

# Extraball – Listado de ramas (man git-branch)

$ git branch

loading

* master

riojaparty

Page 31: Loading...git

Branch

# Merge de ramas

$ git checkout riojaparty

# Commit some changes!

$ git checkout master

$ git merge riojaparty

Updating 6f190b0..a6e1f75

Fast-forward

0 files changed, 0 insertions(+), 0 deletions(-)

create mode 100644 riojaparty_talks.txt

Page 32: Loading...git

Branch

$ git branch remove_me

$ git branch -d remove_me

Deleted branch remove_me (was a6e1f75).

# Extraball

# Borrar rama con cambios no "mergeados" (man git-branch)

$ git branch -D remove_me

Page 33: Loading...git

Tag

# Creando tags

$ git tag v1.0

$ git tag

v1.0

$ git tag beta1 HEAD^

$ git tag

beta1

v1.0

$ git tag beta2 HEAD~5

$ git tag

beta1

beta2

V1.0

# Borrando tags

$ git tag -d beta2

Deleted tag 'beta2' (was f379043)

Page 34: Loading...git

Trabajando en equipo

By Steve Punter - http://www.flickr.com/photos/spunter/2947192314

Page 35: Loading...git

Trabajando en equipo

# Clonando un repositorio

$ git clone foo foo_clone

Initialized empty Git repository in ~/foo_clone/.git/

$ cd foo_clone

$ git remote

origin

$ git remote show origin

* remote origin

Fetch URL: ~/foo

Push URL: ~/foo

HEAD branch (remote HEAD is ambiguous, may be one of the following):

master

riojaparty

Remote branches:

loading tracked

master tracked

riojaparty tracked

Local branch configured for 'git pull':

master merges with remote master

Local ref configured for 'git push':

master pushes to master (up to date)

Page 36: Loading...git

Trabajando en equipo

$ git clone --bare foo foo.git

Initialized empty Git repository in ~/foo.git/

$ ls foo.git/

branches config description HEAD hooks info objects packed-refs refs

Page 37: Loading...git

Trabajando en equipo

# Enviando cambios al repositorio remoto

$ git clone foo.git foo_bare

# Realizamos cambios...

$ git push

Counting objects: 3, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (2/2), done.

Writing objects: 100% (2/2), 250 bytes, done.

Total 2 (delta 1), reused 0 (delta 0)

Unpacking objects: 100% (2/2), done.

To ~/foo.git

c2d55e3..012f07d master -> master

Page 38: Loading...git

Trabajando en equipo

# Actualizando nuestra copia local...

$ git pull

remote: Counting objects: 3, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 2 (delta 1), reused 0 (delta 0)

Unpacking objects: 100% (2/2), done.

From ~/foo

a6e1f75..83a30a8 master -> origin/master

Updating a6e1f75..83a30a8

Fast-forward

0 files changed, 0 insertions(+), 0 deletions(-)

create mode 100644 add_another_file.txt

Page 39: Loading...git

Trabajando en equipo

# Enviando cambios a un repositorio remoto concreto

# Hacemos algunos cambios y entonces...

$ git push origin master

Counting objects: 3, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (2/2), done.

Writing objects: 100% (2/2), 265 bytes, done.

Total 2 (delta 1), reused 0 (delta 0)

Unpacking objects: 100% (2/2), done.

To ../foo.git

012f07d..0a5d1cd master -> master

Page 40: Loading...git

Conflictos

By NWharry - http://www.flickr.com/photos/nightwing_26/5151831220/

Page 41: Loading...git

Extras

● Stash● Blame● Bisect● Ramas y tags remotos● Workflows● …

Page 42: Loading...git

¡Gracias!

By woodleywonderworks - http://www.flickr.com/photos/wwworks/4759535950/

Page 43: Loading...git

Enlaces

Git - http://git-scm.com/

Tutoriales y libros:

Git Immersion - http://gitimmersion.com/

Pro Git (Scott Chacon) - http://www.humbug.in/docs/pro-git-book-es/

Pragmatic Guide To Git - http://pragprog.com/titles/pg_git/pragmatic-guide-to-git

Pensamientos:

Joel on Software - http://www.joelonsoftware.com/items/2010/03/17.html

Presentaciones:

Git 101 - http://www.slideshare.net/chacon/git-101-presentation

The everyday developer's guide to version control with Git - http://www.slideshare.net/erincarter/the-everyday-developers-guide-to-version-control-with-git

Git - http://www.slideshare.net/jnewland/git-512895

Git Started With Git - http://www.slideshare.net/qrush/git-started-with-git

Page 44: Loading...git