View
346
Download
0
Embed Size (px)
Citation preview
Fernando EscolarDevelopment & Cloud Lead [email protected]@fernandoescolar
TOKIOTA, the Microsoft leading partner for innovative technology solutions, empowering our customers while taking care of our people.
clone# este comando lo usamos para conectarnos con un repositorio de git $ git clone my-remote http://my-git.com/repository
remote# con esto añadimos otro repositorio servidor con alias "tokiota" a nuestro repositorio local $ git remote add tokiota https://tokiota.com/gits/repo.git # así listamos todos los servidores que tenemos asociados $ git remote -v
branches# así creamos una rama $ git checkout -b my-branch # así cambiamos a esa rama $ git checkout my-branch
commit local# creamos un conjunto de cambios con el comentario entrecomillado $ git commit -m "#Tarea - Red" # otro commit para cuando pasan los tests $ git commit -m "#Tarea - Green" # creamos el último conjunto de cambios $ git commit -m "#Tarea - Refactor" # enviamos todos los commits locales al servidor $ git push my-remote
logs# así sacamos los commits de la branch actual $ git log
commit a8a7bfff366350be2e7c21b8de9cc6504678a61b` Author: Me <[email protected]> Date: ...
commit e5e3e4c1ef46ae64aa08e8ab3f988bc917ee1ce4 Author: Me <[email protected]> Date: ...
...
# Esto: $ git pull my-remote # Es aproximadamente esto: $ git fetch my-remote $ git merge my-branch
fetch & merge
# Desatachamos el HEAD, que es lo mismo que no tener ninguna rama desprotegida: $ git checkout dd1d7ab32 # si quieres hacer cambios mientras estás en este estado extraño: $ git checkout -b old-state dd1d7ab32
temporalmente
# Primero no tendrás que tener nada modificado. Todo en commits. # Después borramos el cambio: $ git reset --hard dd1d7ab32 # Si quieres guardar el código modificado, porque no quieres hacer un commit: $ git stash git reset --hard dd1d7ab32 git stash pop
si no hemos publicado
# Esto crea 3 commits separados que desacen los commits indicados:$ git revert a867a4ad 25eff4ca a766c053 # También lo podemos hacer por rango. Borrando los dos últimos commits: $ git revert HEAD~2..HEAD # O podemos tirar para atrás un commit de tipo MERGE: $ git revert -m 1 <merge_commit_sha>
si ya está publicado
Comando base Resultado inutil Comando útil Resultado esperadogit branch foo Creates a branch but does nothing with it git checkout -b foo Creates branch and switches to it
git remote Shows names of remotes git remote -v Shows names and URLs of remotes
git stash Stores modifications to tracked files, then rolls them back
git stash -u Also does the same to untracked files
git branch Lists names of local branches git branch -rv Lists local and remote tracking branches; shows latest commit message
git rebase Destroy history blindfolded git rebase -i Lets you rewrite the upstream history of a branch, choosing which commits to keep, squash, or ditch.
git reset foo Unstages files git reset –hardgit reset –soft
Discards local modificationsReturns to another commit, but doesn’t touch working directory.
git add Nothing – prints warning git add .git add -A
Stages all local modifications/additionsStages all local modifications/additions/deletions
Hall of shame
¡Muchas gracias!
http://es.slideshare.net/fernandoescolar/gapand-por-qu-odio-githttp://fernandoescolar.github.io/2016/02/16/por-que-odio-git/@[email protected]