Capítulo 2 Git (Parte 1)

Description

Desde 2.2 a 2.4 inclusive
Joaquín F
Flashcards by Joaquín F, updated more than 1 year ago
Joaquín F
Created by Joaquín F almost 10 years ago
79
0

Resource summary

Question Answer
Guardar cambios en el repositorio Requiere algunos cambios, y confirmar instantáneas de esos cambios a tu repositorio.
Estados de los archivos -Bajo seguimento (tracked) -Sin seguimento (untracked)
Bajo seguimento (tracked) Los archivos bajo seguimiento son aquellos que existían en la última instantánea; pueden estar sin modificaciones, modificados, o preparados.
-Sin seguimiento (untracked) Cualquier archivo de tu directorio que no estuviese en tu última instantánea ni está en tu área de preparación.
Ciclo de vida de los archivos
Comando para comprobar el estado de los archivos git status Respuesta: $ git status # On branch master nothing to commit, working directory clean
Al añadir un archivo a un proyecto y el archivo no existía al ejecutar "git status" $ vim README $ git status # On branch master # 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)
Seguimiento de nuevos archivos Comando "git add" ¿Preparado? Cabecera "Changes to be committed". Si confirmas ahora, la versión del archivo en el momento de ejecutar git add será la que se incluya en la instantánea.
Modificar archivo bajo seguimiento Ejecutar "status" Respuesta: $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # # modified: benchmarks.rb #
Cabecera "Modificados pero no actualizados" Significa que un archivo bajo seguimiento ha sido modificado en el directorio de trabajo, pero no ha sido preparado todavía.
Comando para preparar "git add"
Respuesta $ git add benchmarks.rb $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # modified: benchmarks.rb #
Modificar el archivo Al ejecutar "git status", muestra: $ vim benchmarks.rb $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # modified: benchmarks.rb # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # # modified: benchmarks.rb #
¿Por qué el archivo aparece listado como preparado y como no preparado? Git prepara un archivo tal y como era en el momento de ejecutar el comando git add. Si haces git commit ahora, la versión que se incluirá en la confirmación será la que fuese cuando ejecutaste el comando git add. Si modificas un archivo después de haber ejecutado git add , tendrás que volver a ejecutar git add para preparar la última versión.
Respuesta $ git add benchmarks.rb $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # modified: benchmarks.rb #
Ignorar archivos generados automáticamente. Ejemplo: .gitignore Ejecutar: $ cat .gitignore *.[oa] *~
Comandos para ignorar *.[oa] = ignora archivos con extensión .o y .a *~ = ignora todos los archivos que terminan en tilde ( ~ )
Configurar un archivo .gitignore Reglas para los patrones: Se puede: Las líneas en blanco, o que comienzan por #, son ignoradas. -Usar patrones glob estándar. -Indicar un directorio añadiendo una barra hacia delante ( / ) al final. -Negar un patrón añadiendo una exclamación ( ! ) al principio.
Patrones glob Son expresiones regulares simplificadas que pueden ser usadas por las shells. Un asterisco ( * ) reconoce cero o más caracteres; [abc] reconoce cualquier carácter de los especificados entre corchetes (en este caso, a, b o c); una interrogación ( ? ) reconoce un único carácter; y caracteres entre corchetes separados por un guión ([0-9] ) reconoce cualquier carácter entre ellos (en este caso, de 0 a 9).
Cambios preparados y no preparados Comando "git diff" responde a preguntas: ¿qué has cambiado pero aún no has preparado?, y ¿qué has preparado y estás a punto de confirmar?
Confirmar los cambios Comando "git commit"
Respuesta # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # modified: benchmarks.rb ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 283C
Saltear el área de preparación Comando: "git commit -a"
Respuesta $ git status # On branch master # # Changes not staged for commit: # # modified: benchmarks.rb # $ git commit -a -m 'added new benchmarks' [master 83e38c7] added new benchmarks 1 files changed, 5 insertions(+), 0 deletions(-)
Eliminar archivos Comando "git rm" elimina archivo del área de preparación
Respuesta $ git rm grit.gemspec rm 'grit.gemspec' $ git status # On branch master # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: grit.gemspec #
Eliminar de git sin eliminar del disco duro Comando: $ git rm --cached readme.txt
Forzar la eliminación de archivos ya modificados y en el área de preparación Opción -f
Renombrar archivos comando "mv"
Respuesta $ git mv README.txt README $ git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: README.txt -> README #
Ver historial de confirmaciones Comando "git log"
Respuesta $ git log commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test code commit a11bef06a3f659402fe7563abf99ad00de2209e6 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 10:31:28 2008 -0700 first commit
Opciones de "git log" -p: muestra las diferencias introducidas en cada confirmación. -2: que hace que se muestren únicamente las dos últimas entradas del historial.
Revisar cambios a nivel palabra Comando --word-diff
Respuesta $ git log -U1 --word-diff commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number diff --git a/Rakefile b/Rakefile index a874b73..8f94139 100644 --- a/Rakefile +++ b/Rakefile @@ -7,3 +7,3 @@ spec = Gem::Specification.new do |s| s.name = "simplegit" s.version = [-"0.1.0"-]{+"0.1.1"+} s.author = "Scott Chacon"
Ver estadísticas de cada confirmación Comando: "$ git log --stat"
Respuesta commit ca82a6dff817ec66f44342007202690a93763949 Author: Scott Chacon <schacon@gee-mail.com> Date: Mon Mar 17 21:52:11 2008 -0700 changed the version number Rakefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 16:40:33 2008 -0700 removed unnecessary test code lib/simplegit.rb | 5 ----- 1 files changed, 0 insertions(+), 5 deletions(-) commit a11bef06a3f659402fe7563abf99ad00de2209e6 Author: Scott Chacon <schacon@gee-mail.com> Date: Sat Mar 15 10:31:28 2008 -0700 first commit README | 6 ++++++ Rakefile | 23 +++++++++++++++++++++++ lib/simplegit.rb | 25 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 0 deletions(-)
Opciones -"--pretty" Modifica el formato de la salida -"oneline" imprime cada confirmación en una única línea -"short , full y fuller":agregan o disminuyen información
Opción "format" Especifica un determinado formato
Respuesta $ git log --pretty=format:"%h - %an, %ar : %s" ca82a6d - Scott Chacon, 11 months ago : changed the version number 085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code a11bef0 - Scott Chacon, 11 months ago : first commit
Opciones de "format" Opción Descripción de la salida %H Hash de la confirmación %h Hash de la confirmación abreviado %T Hash del árbol Opción Descripción de la salida %t Hash del árbol abreviado %P Hashes de las confirmaciones padre %p Hashes de las confirmaciones padre abreviados %an Nombre del autor %ae Dirección de correo del autor %ad Fecha de autoría (el formato respeta la opción -–date ) %ar Fecha de autoría, relativa %cn Nombre del confirmador %ce Dirección de correo del confirmador %cd Fecha de confirmación %cr Fecha de confirmación, relativa %s Asunto
opción "--graph" Acompaña a "oneline" y "format": muestra historial, ramificaciones y uniones.
Respuesta $ git log --pretty=format:"%h %s" --graph * 2d3acf9 ignore errors from SIGCHLD on trap * 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit |\ | * 420eac9 Added a method for getting the current branch. * | 30e367c timeout code and tests * | 5a09431 add timeout protection to grit * | e1193f8 support for heads with slashes in them |/ * d6016bc require time for xmlschema * 11d191e Merge branch 'defunkt' into local
Opciones de "git log" para limitar las confirmaciones que se muestran -(n) Muestra solamente las últimas n confirmaciones --since, --after Muestra aquellas confirmaciones hechas después de la fecha especificada. --until, -- before --author Muestra sólo aquellas confirmaciones cuyo autor coincide con la cadena especificada. --committer Muestra aquellas confirmaciones hechas antes de la fecha especificada. Muestra sólo aquellas confirmaciones cuyo confirmador coincide con la cadena especificada.
Interfaz gráfica Tcl/Tk permite visualizar el historial
Deshacer una confirmación Comando "$ git commit --amend"
Deshacer la preparación de un archivo Comando "reset HEAD <archivo>..."
Respuesta $ git reset HEAD benchmarks.rb benchmarks.rb: locally modified $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README.txt # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: benchmarks.rb #
Deshacer la modificación de un archivo Comando "git checkout -- <file>..."
Respuesta $ git checkout -- benchmarks.rb $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: README.txt #
Opción "--amend" Deshace cualquier cosa que esté confirmada
Show full summary Hide full summary

Similar

Sociological Perspectives
dousl002
Romeo and Juliet essay
Tambo234
Hitler's Chancellorship
c7jeremy
Of Mice and Men - Themes
Hafsa A
anatomy of the moving body: Skeletal system
Rupa Kleyn
Edexcel Additional Science Chemistry Topics 1+2
hchen8nrd
Tests for Positive Ions: Flame Test Colours
bella.mort
Respiratory anatomy
James Murdoch
Carbohydrates
kevinlinkovoor
The Reformation
keeva byrne
How to Study Smart
Abdou Mohamed