Skip to content

Instantly share code, notes, and snippets.

@FrancoStino
Forked from vanquang9387/git-export.md
Created July 29, 2024 14:19
Show Gist options
  • Save FrancoStino/c5078b3b31e0a2062a8d244464b456bf to your computer and use it in GitHub Desktop.
Save FrancoStino/c5078b3b31e0a2062a8d244464b456bf to your computer and use it in GitHub Desktop.
git: export diff files between 2 branches/commits

We can get list of changed files between 2 branches/commits by

$ tar --ignore-failed-read -vczf archive.tgz $(git diff --name-only --diff-filter=ACMRT master develop)

Let's see important part:

  1. git diff master develop:
    Get differences between master and develop branches.

  2. --name-only:
    Output only the names of the affected files instead of a full diff.

  3. --diff-filter=ACMRT:
    Only show files added, copied, modified, renamed or that had their type changed (eg. file → symlink) in this commit. This leaves out deleted files.

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