Skip to content

Instantly share code, notes, and snippets.

@irineujunior
Forked from emmanueltissera/git-apply-patch.md
Last active November 7, 2019 13:00
Show Gist options
  • Save irineujunior/5f6ebf61ab810c1beeca4e27921fd4a6 to your computer and use it in GitHub Desktop.
Save irineujunior/5f6ebf61ab810c1beeca4e27921fd4a6 to your computer and use it in GitHub Desktop.
Generate a git patch for a specific commit

Criação

git format-patch -n <hash>

onde o -n é o número de commits a partir do hash

Ex. Para gerar 7 arquivos de patch a partir do HEAD git format-patch -7 HEAD

Aplicação

checa status

git apply --stat file.patch

verifica possiveis conflitos

git apply --check file.patch

aplica o path

git apply file.patch

use o --exclude=(*string*) para remover os arquivos que possam causar conflito

Source: https://stackoverflow.com/questions/6658313/generate-a-git-patch-for-a-specific-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment