Cómo aplicar un parche de git cuando se le da un número de extracción
He descargado una versión troncal de una base de código de git, y hay errores de compilación. Aparentemente un parche está ahora disponible, y recibí un correo electrónico :
Véase https://github.com/JustinTulloss/zeromq.node/pull/47 para el parche
Soy nuevo en git, así que no estoy muy seguro de qué hacer con este 'parche' especialmente, ya que la página se parece más a un hilo de discusión.
¿Alguien sabe cómo puedo obtener/aplicar este parche a mi repositorio git clonado localmente?
5 answers
Guarde el parche en algún lugar. Si estás usando Linux puedes usar curl:
curl -L https://github.com/JustinTulloss/zeromq.node/pull/47.patch > /tmp/47.patch
Para aplicar el parche use git apply
. Puede ver si el parche se aplicará limpiamente con la opción check
. Cambia a tu directorio git y ejecuta:
git apply --check /tmp/47.patch
Si parece que desea aplicar el parche, retire la opción de verificación
git apply /tmp/47.patch
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-08 15:30:58
Simplemente agregue un .patch
al final para obtener el parche:
Https://github.com/JustinTulloss/zeromq.node/pull/47.patch
Puedes hacer algo como a continuación:
$ git checkout master
$ curl http://github.com/JustinTulloss/zeromq.node/pull/47.patch | git am
$ git push origin master
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-19 19:44:54
La regla parece haber cambiado recientemente.
Anteriormente tomamos un PR y agregamos un .patch
al final para obtener el parche
http://github.com/[group]/[project]/pull/30583.patch
Pero ahora el enlace es redirect (301) a
https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch
Así que si usas curl
, podrías canalizar con el comando git apply
para aplicar un parche git desde la solicitud de extracción
curl https://patch-diff.githubusercontent.com/raw/[group]/[project]/pull/30583.patch | git apply
Si el parche no es adecuado para usted ahora, use el comando git apply -R
para revertir el cambio.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-08-05 21:07:48
Para dejar que git descargue pull request 47 y lo remiende a mylocalbranch
localmente, ejecute:
git checkout -b mylocalbranch
git pull origin pull/47/head
Si la solicitud de extracción no está en el repositorio de origen, ejecute
git remote add patchremote https://github.com/JustinTulloss/zeromq.node
git pull patchremote pull/47/head
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-05 23:04:14
git fetch -q origin +refs/pull/47/merge:
git checkout -qf FETCH_HEAD
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-02-25 10:36:25