Loading...git
-
Upload
rafael-garcia -
Category
Technology
-
view
659 -
download
0
Transcript of Loading...git
whoami
Rafa García
Web developerAdministrador de Sistemas
Entusiasta del software libre
¡Encuesta rápida!
● ¿Quién NO está usando un SCM?
¡Encuesta rápida!
● ¿Quién NO está usando un SCM?● ¿Subversion?
¡Encuesta rápida!
● ¿Quién NO está usando un SCM?● ¿Subversion?● ¿CVS? (¿todavía?)
¡Encuesta rápida!
● ¿Quién NO está usando un SCM?● ¿Subversion?● ¿CVS? (¿todavía?)
C'est la vie
Le Voyage Magnifique es obra de Debra Chow - http://vimeo.com/6846068
¿Qué es Git?
¿Qué es Git?
Git sistema de control de versiones distribuido, open source,
diseñado para ser rápido y eficiente.
¿Por qué Git?
● Distribuido● ¡Es muy rápido!● Branching● Workflows● Una gran comunidad detrás
Configurar Git
By Twicepix - http://www.flickr.com/photos/twicepix/4288056667/
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
Crear repositorio
$ mkdir foo
$ cd foo/
~/foo$ git init
Initialized empty Git repository in ~/foo/.git/
Trabajando con Git
Estado del repositorio
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
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)
Stage
$ git add README
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
#
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
Ignorar ficheros
$ cat .gitignore
.bundle/
db/sphinx/*
log/**/*
log/*
tmp/**/*
tmp/*
.rvmrc
Deshaciendo cambios
By Gaelx - http://www.flickr.com/photos/gaelx/2664672458/
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)
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
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(-)
Deshaciendo cambios
By Stan Lee
Deshaciendo cambios
$ git reset --hard HEAD^^^
# Que es lo mismo que...
$ git reset --hard HEAD~3
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^
Branch
By n8agrin - http://www.flickr.com/photos/n8agrin/2735063012/
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'
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
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
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
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)
Trabajando en equipo
By Steve Punter - http://www.flickr.com/photos/spunter/2947192314
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)
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
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
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
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
Conflictos
By NWharry - http://www.flickr.com/photos/nightwing_26/5151831220/
Extras
● Stash● Blame● Bisect● Ramas y tags remotos● Workflows● …
¡Gracias!
By woodleywonderworks - http://www.flickr.com/photos/wwworks/4759535950/
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