
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
gh-diff-extractor
Advanced tools
A CLI tool to extract git diffs from GitHub pull request files pages, supporting private repositories
A CLI tool to extract git diffs from GitHub pull request files pages, supporting private repositories.
/files pages)npm install -g gh-diff-extractor
npm install gh-diff-extractor
To access private repositories, you need a GitHub Personal Access Token. The tool supports multiple ways to provide authentication:
export GITHUB_TOKEN=your_github_token_here
gh-diff-extractor config --token your_github_token_here
gh-diff-extractor --token your_github_token_here <url>
repo (for private repositories)public_repo (for public repositories)# Extract diff from a public PR
gh-diff-extractor https://github.com/owner/repo/pull/123
# Extract diff from a private PR (requires authentication)
gh-diff-extractor https://github.com/owner/repo/pull/123/files
# Get patch format instead of diff
gh-diff-extractor --patch https://github.com/owner/repo/pull/123
# Save to file
gh-diff-extractor --output pr-123.diff https://github.com/owner/repo/pull/123
# Show statistics
gh-diff-extractor --stats https://github.com/owner/repo/pull/123
# Disable colours
gh-diff-extractor --no-color https://github.com/owner/repo/pull/123
The tool accepts various GitHub PR URL formats:
https://github.com/owner/repo/pull/123https://github.com/owner/repo/pull/123/fileshttps://github.com/owner/repo/pull/123/commitsgithub.com/owner/repo/pull/123 (protocol will be added automatically)Usage: gh-diff-extractor [options] <url>
Arguments:
url GitHub pull request URL
Options:
-V, --version output the version number
-t, --token <token> GitHub personal access token
-o, --output <file> Output file path (if not specified, prints to stdout)
-p, --patch Get patch format instead of diff format
-v, --verbose Show verbose output
--no-color Disable coloured output
--stats Show diff statistics
-h, --help display help for command
# Set GitHub token
gh-diff-extractor config --token your_github_token_here
# Validate token
gh-diff-extractor validate
# Validate specific token
gh-diff-extractor validate --token your_github_token_here
gh-diff-extractor --stats https://github.com/facebook/react/pull/25123
Output:
Files changed: 3, Insertions: 45, Deletions: 12
diff --git a/packages/react/src/React.js b/packages/react/src/React.js
index 1234567..abcdefg 100644
--- a/packages/react/src/React.js
+++ b/packages/react/src/React.js
...
gh-diff-extractor --output react-pr-25123.diff https://github.com/facebook/react/pull/25123
gh-diff-extractor --patch https://github.com/facebook/react/pull/25123
The tool provides clear error messages for common issues:
git clone https://github.com/Sharma-IT/gh-diff-extractor.git
cd gh-diff-extractor
npm install
npm test
npm run test:coverage
npm run build
npm run dev -- https://github.com/owner/repo/pull/123
MIT License - see LICENSE file for details.
If you encounter any issues or have questions:
FAQs
A CLI tool to extract git diffs from GitHub pull request files pages, supporting private repositories
We found that gh-diff-extractor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.