GITHUB-avanzado: Manual para realizar modificaciones en repos de Github.
- CREADO POR: miguelajsmaps@gmail.com en https://github.com/Miguel-J/eneboo/wiki (YA NO EXISTE)
- FECHA CREACIÓN:
- ACTUAL: miguelajsmaps@gmail.com en http://manuales-eneboo-pineboo.org/github-como-instalarlo-y-usarlo/github-como-sincronizar-dos-repositorios/github-avanzado-repos-y-ramas/
- ULTIMA ACTUALIZACIÓN:Last updated: enero 8, 2021 at 19:57 pm
GITHUB-avanzado – repos y ramas
Indice:
- Asociar dos repos distintos (sin ser ramas)»
- UNIR SÓLO ALGUNOS COMMITS CON GIT CHERRY-PICK (PULL REQUESTS PARCIALES):
- ELIMINAR UN COMMIT DEL HISTORIAL:
- 20. DESHACER UN COMMIT ANTIGUO:
Haz clic aquí para volver al índice
1. ASOCIAR DOS REPOS DISTINTOS (sin ser ramas entre sí)
1. LISTAR LAS RAMAS:
1 2 |
$ git branch |
Si lo lanzas sin argumentos, obtienes una lista de las ramas presentes en tu proyecto.
Haz clic aquí para volver al índice
2. ASOCIAR OTROS REPOS:
Para añadir un nuevo repositorio Git remoto, asignándole un nombre con el que referenciarlo fácilmente, ejecuta git remote add [nombre]
1 2 |
C:\github\eneboo-features-oficial [master]> git remote add ef git://github.com/Miguel-J/eneboo-features.git |
Haz clic aquí para volver al índice
3. LISTAR REPOS ASOCIADOS:
1 2 3 4 5 6 |
`C:\github\eneboo-features-oficial [master]> git remote -v ef git://github.com/Miguel-J/eneboo-features.git (fetch) ef git://github.com/Miguel-J/eneboo-features.git (push) origin https://github.com/Miguel-J/eneboo-features-oficial (fetch) origin https://github.com/Miguel-J/eneboo-features-oficial (push) |
Haz clic aquí para volver al índice
4. IMPORTAR EL CÓDIGO DE OTRO REPO EN SUB-«RAMAS»
1 2 |
C:\github\eneboo-features-oficial [master]> git fetch ef |
Haz clic aquí para volver al índice
5. CREAR UNA RAMA:
1 |
C:\github\eneboo-features-oficial [master]> git branch ef |
Haz clic aquí para volver al índice
6. CAMBIAR DE RAMA:
1 2 3 4 |
C:\github\eneboo-features-oficial [master]> git checkout ef Switched to branch 'ef' C:\github\eneboo-features-oficial [ef]> |
Haz clic aquí para volver al índice
7. TRAER CAMBIOS DEL OTRO REPO:
C:\github\eneboo-features-oficial [ef/master]> git pull https://github.com/Miguel-J/eneboo-features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
remote: Counting objects: 270, done. Receiving objects: 100% (270/270), 170.52 KiB | 0 bytes/s, done.sed 129 `Resolving deltas: 100% (152/152), completed with 62 local objects.` `From https://github.com/Miguel-J/eneboo-features` `* branch HEAD -> FETCH_HEAD` `Auto-merging ext0450-envio_mail/patches/envio_mail/masterpresupuestoscli.qs` `CONFLICT (content): Merge conflict in ext0450-envio_mail/patches/envio_mail/masterpresupuestoscli.qs` `Auto-merging ext0450-envio_mail/patches/envio_mail/masterpedidoscli.qs` `CONFLICT (content): Merge conflict in ext0450-envio_mail/patches/envio_mail/masterpedidoscli.qs` `Auto-merging ext0450-envio_mail/patches/envio_mail/masterfacturascli.qs` `CONFLICT (content): Merge conflict in ext0450-envio_mail/patches/envio_mail/masterfacturascli.qs` `Auto-merging ext0450-envio_mail/patches/envio_mail/masteralbaranescli.qs` `CONFLICT (content): Merge conflict in ext0450-envio_mail/patches/envio_mail/masteralbaranescli.qs` `Automatic merge failed; fix conflicts and then commit the result.` `C:\github\eneboo-features-oficial [ef/master +32 ~36 -0 !4 | +0 ~0 -0 !4]>` |
Haz clic aquí para volver al índice
8. ELIMINAR PROBLEMAS:
????
1 2 |
"error: you need to resolve your current index first" |
http://schacon.github.io/git/user-manual.html#resolving-a-merge
1 2 3 4 5 |
`"All you need to do is edit the files to resolve the conflicts, and then` `$ git add file.txt` `$ git commit` `"` |
—
copio los 4 archivos en el «repo-puente de klo» (local)…
…subo al «repo-puente de klo» (online)…
9. UNIR LAS DOS RAMAS:
…ramifico ese «repo-puente-modificado» en el «repo-copia-de-eneboo-local»…
1 2 3 |
?????...quieres decir que el "fetch" era necesario? C:\github\eneboo-features-oficial [master]> git pull https://github.com/Miguel-J/eneboo-features |
…subo cambios al «repo-copia-de-eneboo-online»…
1 2 |
C:\github\eneboo-features-oficial [master]> git push https://github.com/Miguel-J/eneboo-features-oficial master |
…hago «pull-request» desde «repo-copia-de-eneboo-online» con los commits de klo HACIA repo-eneboo-features de Eneboo…
…a esperar el «merge»…o no.
…borro «repo-puente-modificado» y vuelvo a hacer fork del «repo-klo»…
Haz clic aquí para volver al índice
2. VARIOS:
https://elbauldelprogramador.com/mini-tutorial-y-chuleta-de-comandos-git/
Haz clic aquí para volver al índice
3. UNIR SÓLO ALGUNOS COMMITS CON GIT CHERRY-PICK (PULL REQUESTS PARCIALES):
- Han rechazado el Pull Request total
- Elimino los dos repos (el copia de eneboo-oficial y el copia de klo) y los vuelvo a descargar
- Hago un «git pull» del klo HACIA el eneboo-oficial….vuelve a dar error en «ext450»
- Elimino la carpeta «ext450» en klo y le meto la «ext450» de «eneboo-oficial»
- Hago un «add./commit-a/push» en el de klo-local hacia el klo-remoto
- Vuelvo a hacer un «git pull» del klo-remoto HACIA el eneboo-oficial-local…lo aplica bien.
- Hago un «push» en el de eneboo-oficial-local hacia el eneboo-oficial-remoto
- Ahora LOS DOS REMOTOS SON IGUALES (con ext450 de «eneboo-oficial»)
- Hago un fork en «Arreglogithub» de «eneboo-features-oficial», envío un Pull-Request TOTAL desde Miguel-J, borro el repo en Miguel-J y hago otro fork de «eneboo-features-oficial»
- Ahora LOS DOS REMOTOS SON DISTINTOS: «klo-remoto» y «arreglogithub» son IGUALES (con ext450 de «eneboo-oficial») pero «eneboo-oficial» es el original de «eneboo-features».
- Añado la relación del repo «arreglogithub» EN EL repo «eneboo-oficial»:
12C:\GitHub\eneboo-features-oficial [master]> git remote add arreglogithub git://github.com/arreglogithub/eneboo-features-oficial.git - Añado el contenido de esa relación:
123456789C:\GitHub\eneboo-features-oficial [master]> git fetch arreglogithubremote: Counting objects: 286, done.Receiving objects: 100% (286/286), 148.51 KiB | 0 bytes/s, done.ed 140 eceiving objects: 97% (278/286)Resolving deltas: 100% (160/160), completed with 62 local objects.From git://github.com/arreglogithub/eneboo-features-oficial* [new branch] master -> arreglogithub/masterC:\GitHub\eneboo-features-oficial [master]> - (Opcional): Lista de «commits»:
12C:\GitHub\eneboo-features-oficial [master]> git log arreglogithub/master - Escoger el commit a importar/enviar:
123456C:\GitHub\eneboo-features-oficial [master]> git cherry-pick c245e97[master ef86611] arreglo funcion vaciar tablas y añado el qryDate: Fri Nov 27 11:06:59 2015 +01003 files changed, 34 insertions(+), 4 deletions(-)create mode 100644 ext0068-info_ventascli/patches/info_ventascli/i_ventascli.qry - Envio el cambio a eneboo-oficial-remoto con «push»
- Envio el Pull-Request (PARCIAL) desde la web (eneboo-oficial-remoto) HACIA REPO-PADRE.
- Volver a hacerlo para cada commit….bufff
Haz clic aquí para volver al índice
SOLUCIONAR CONFLICTOS
https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/
Para desbloquear un conflicto si ya has borrado el archivo:
git reset
Haz clic aquí para volver al índice
20. DESHACER UN COMMIT ANTIGUO:
https://gist.github.com/ gunjanpatel/ 18f9e4d1eb609597 c50c2118e416e6a6
Revert the full commit
Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}’
Revertir el compromiso completo
A veces es posible que desee deshacer una confirmación completa con todos los cambios. En lugar de pasar por todos los cambios de forma manual, simplemente puede decirle a git que revierte una confirmación, que ni siquiera tiene que ser la última. Revertir un compromiso significa crear un nuevo compromiso que deshaga todos los cambios que se hicieron en el compromiso incorrecto. Al igual que en el ejemplo anterior, el compromiso incorrecto permanece allí, pero ya no afecta al maestro actual ni a cualquier compromiso futuro que se encuentre encima.
git revert {commit_id} ‘
EJEMPLO:
git revert 49cc5d7
Haz clic aquí para volver al índice
ELIMINAR UN COMMIT DEL HISTORIAL:
Haz clic aquí para volver al índice
Cómo cambiar de rama en GITHUB:
https://github.com/lsel2014/lsel2014/ wiki/C%C3%B3mo-cambiar-de-rama-en-git
Por lo general, no se debe trabajar en la rama principal master. Se debe crear una nueva por cada funcionalidad que luego será ‘mergeada’ junto con las demás al master.
Para crear una rama nueva en local: git checkout -b "nombre_rama"
Para bajarse el código del repositorio en GitHub de una rama distinta git pull origin <nombre_rama>
Para subir el código a la rama del repositorio en GitHub: git push origin <nombre_rama>
EDIT: Si se hace un git pull, se bajan todas las ramas. Se puede cambiar de rama en el momento con git checkout «nombre_rama» si ya está creada.
Haz clic aquí para volver al índice