Skip to content

Instantly share code, notes, and snippets.

@Overbryd
Last active October 7, 2020 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Overbryd/635dd371ac85b0b68874a421cb027964 to your computer and use it in GitHub Desktop.
Save Overbryd/635dd371ac85b0b68874a421cb027964 to your computer and use it in GitHub Desktop.
The following describes the necessary steps to apply a git patch on a repository export

Assuming you have a <workdir> directory, that contains the unzipped contents of a repository export/tarball. That directory is called <repository export>.

  • Enter the directory of the repository export

    $ cd <workdir>/<repository export>
  • Initialize an empty git-repository on the export

    $ git init
    Initialized empty Git repository in <workdir>/<repository export>/.git/
    $ git add .
    $ git commit -m 'Initial commit of <repository export> on a new git history'
  • Assuming the patch is to be found in ~/Downloads/repo.patch

  • Apply the patch on the newly initialized git-repository

    Note: If you are using git-crypt, you must ignore the .git-crypt folder and its changes if the patch does not apply.

    $ git apply --binary --exclude=.git-crypt/* ~/Downloads/repo.patch
    $ git commit -m 'Applying changes since <repository export> on this git history'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment