Last active
November 27, 2023 10:34
-
-
Save janglapuk/2e84fbc6faa5dda486ecdb2f45fccc23 to your computer and use it in GitHub Desktop.
Git archive cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # archive HEAD | |
| git archive --output=archive.zip HEAD | |
| # archive HEAD with directory prefix (like github ZIP archive) | |
| git archive --output=archive.zip --prefix=main HEAD | |
| # archive changes between two commits (bash) | |
| git archive --output=archive.zip HEAD $(git diff --name-only commit_ID_A commit_ID_B) | |
| # archive changes between two commits (PowerShell) | |
| git diff --name-only commit_ID_A commit_ID_B | Out-File -Encoding ASCII changes.txt | |
| git archive --output=archive.zip HEAD -- $(Get-Content changes.txt) | |
| # archive HEAD with excluded file/directory from .gitignore (e.g. .env, vendor, node_modules, etc.) | |
| git archive --output=archive.zip HEAD | |
| 7z a -r archive.zip vendor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment