Upload
eduard-castro
View
217
Download
0
Embed Size (px)
Citation preview
8/17/2019 Operaciones Git
1/3
############################################## Push de la rama actualgit push origin $rama_actual
############################################## Volver a un commit anterior, descartando los cambiosgit reset --HARD $SHA1
############################################## Ver y descargar Ramas remotasgit remote show origin# Si hay alguna rama de la cual no tengamos los datos aúngit fetch origin# Obtener la rama remotagit checkout --track -b $rama origin/$rama# más simplegit checkout -t origin/$rama
git branch -a# * master# remotes/origin/HEAD -> origin/master# remotes/origin/baremacion# remotes/origin/bootstrap# remotes/origin/fallo_registro
# remotes/origin/mastergit checkout -b baremacion remotes/origin/baremacion#############################################
# Crear una rama basada en el HEADgit branch $branch
# Crear una nueva rama basada en el branch $othergit checkout -b $new_branch $other
# Eliminar una rama localgit branch -d $branch
# Eliminar una rama remotagit push origin :$branch
# Eliminar las ramas remotas que ya no existan en origin (Ambos comandos hacen lo mismo)# Ejecutar con --dry-run para ver los cambios que realizarágit fetch -pgit remote prune origin#############################################
# Cambiar el nombre de una ramagit branch -m $nombre_rama_anterior $nombre_rama_nuevo
############################################## Ignorar el salto de línea en Git http://help.github.com/line-endings/git config --global core.autocrlf input
############################################## Copiar un commit determinado a una rama cualquieragit checkout $ramagit cherry-pick $SHA1
#############################################
8/17/2019 Operaciones Git
2/3
# Trabajando con tags
# Ver los tags localesgit tag
# Añadir un taggit tag -a v1.2 $SHA1
# Subir tags al repositoriogit push --tags
############################################### Deshacer el último commit (sin haber hecho push)git reset --soft HEAD~1
# Deshacer el último commit (habiendo hecho ya un push)git revert HEAD
############################################### Subir a la rama Commits parciales (los ficheros que no añado se quedan en el stash y se recuperan luego)git add $filegit commit -m "Mensaje"git stash
git pull --rebase origin $ramagit push origin ramagit stash pop
# list commits not pushed to the origin yetgit log origin/master..master
# list remote branches that contain $commitgit branch -r --contains $commit
# Deshacer el último commit (dejándolo como estaba con los archivos añadidos y demás)git reset --soft HEAD^
############################################### Reescribiendo la "historia"# - Deshacer commits# - Unir commits# - Reordenar commits# - ...git rebase -i HEAD~10 # Esto mira los 10 últimos
# Y veremos algo como esto:pick ce2b738 Commit message 1pick 2a3cdf7 Commit message 2
# Y podremos realizar las siguientes operaciones sobre los commits
# inlcuyendo reordenar los commits# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell
# Establecer la fecha de los commits anterior al rebase => git committer date =git author date
8/17/2019 Operaciones Git
3/3
git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_ COMMITTER_DATE' ..HEAD
############################################### Recuperarse de un desastrehttp://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/