Diga el otro tipo creado barra en la parte superior del foo, pero creado Baz, mientras tanto, y luego se fusionaron, dando una historia de
$ git lola
* 2582152 (HEAD, master) Merge branch 'otherguy'
|\
| * c7256de (otherguy) bar
* | b7e7176 baz
|/
* 9968f79 foo
Nota: git lola es un alias no estándar pero útil.
No hay dados con git revert
:
$ git revert HEAD
fatal: Commit 2582152... is a merge but no -m option was given.
Charles Bailey dio una excellent answer como de costumbre. Usando git revert
como en
$ git revert --no-edit -m 1 HEAD
[master e900aad] Revert "Merge branch 'otherguy'"
0 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 bar
elimina efectivamente bar
y produce una historia de
$ git lola
* e900aad (HEAD, master) Revert "Merge branch 'otherguy'"
* 2582152 Merge branch 'otherguy'
|\
| * c7256de (otherguy) bar
* | b7e7176 baz
|/
* 9968f79 foo
Pero sospecho que deseas tiro de la fusión cometer:
$ git reset --hard HEAD^
HEAD is now at b7e7176 baz
$ git lola
* b7e7176 (HEAD, master) baz
| * c7256de (otherguy) bar
|/
* 9968f79 foo
Como se documenta en el git rev-parse
manual
<rev>^
, e.g. HEAD^, v1.5.1^0
A suffix ^
to a revision parameter means the first parent of that commit object. ^<n>
means the n-th parent (i.e.<rev>^
is equivalent to <rev>^1
). As a special rule, <rev>^0
means the commit itself and is used when <rev>
is the object name of a tag object that refers to a commit object.
así antes de invocar git reset
, HEAD^
(o HEAD^1
) fue b7e7176 y HEAD^2
era c7256de, es decir, respectivamente la primera y segunda padres de la fusión se comprometen.
Tenga cuidado con git reset --hard
porque puede destruir el trabajo.
OK gracias. Me resultó más fácil simplemente cambiar los dos archivos que se vieron afectados por la fusión y luego confirmar algunos de mis otros cambios también. – icnhzabot
¿Dónde puedo encontrar información si tengo que usar -m1 o -m2, ...? –
'git cat-file -p [MERGE_COMMIT_ID]' mostrará las ramas padre en orden. La primera lista sería '-m 1', la segunda' -m 2'. – nostromo