Fusionar hasta un commit específico


He creado una nueva rama llamada newbranch desde la rama master en git. Ahora he hecho un poco de trabajo y desea combinar newbranch a master; sin embargo, he hecho algunos cambios adicionales a newbranch y quiero combinar newbranch hasta el cuarto-de-la-última comprometerse a master.

Usé cherry-pick pero muestra el mensaje para usar las opciones correctas:

git checkout master    
git cherry-pick ^^^^HEAD newbranch

¿Puedo usar git merge para hacerlo?

git merge newbranch <commitid>
Author: Nondeterministic narwhal, 2011-11-22

2 answers

Claro, estando en master rama todo lo que necesitas hacer es:

git merge <commit-id>

Donde commit-id es el hash de la última confirmación de newbranch que desea obtener en su rama master.

Puedes encontrar más información sobre cualquier comando de git haciendo git help <command>. Si ese caso es git help merge. Y los documentos están diciendo que el último argumento para el comando merge es <commit>..., por lo que puede pasar referencia a cualquier confirmación o incluso múltiples confirmaciones. Sin embargo, yo nunca hice esto último.

 438
Author: KL-7,
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
2013-04-23 07:21:28

Para mantener la ramificación limpia, puedes hacer esto:

git checkout newbranch
git branch newbranch2
git reset --hard <commit Id> # the commit at which you want to merge
git checkout master
git merge newbranch
git checkout newbranch2

De esta manera, newbranch terminará donde se fusionó en master, y usted continuará trabajando en newbranch2.

 3
Author: tkruse,
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
2017-12-06 05:16:12