A command-line utility to visually compare changes between two Git revisions using the Meld diff tool.
This script automates the extraction of changed files from specified Git revisions, saves them to temporary directories, and launches Meld for side-by-side comparison.
- Visual Diff: Compares two Git revisions using Meld (can be changed on tool that can compare two folders).
- Customizable: Supports custom paths for Meld, repository, revisions, and log directory.
- Automatic Extraction: Extracts only changed files between revisions.
- Symbolic Linking: Uses symbolic links for current HEAD files for efficiency.
- Logging: Flexible logging options and error handling.
- Python 3.x
- Meld installed and available in your system path
logger.py(custom logging module included or provided separately)- Git installed and available in your system path
- Clone the repository or copy the script files:
git clone <your-repo-url> cd <your-repo-directory>
- Ensure
logger.pyis present in the same directory as the script. - Install Meld (if not already installed):
- On Ubuntu/Debian:
sudo apt-get install meld - On macOS:
brew install meld - On Windows: Download Meld
- On Ubuntu/Debian:
python git_meld_diff.py [options] [rev_old] [rev_new]| Option | Description | Default Value |
|---|---|---|
--meld-exec |
Path to Meld executable | meld |
--dir-repo |
Path to the git repository | Current directory |
--dir-old |
Directory for older revision files | /home/user/temp/compare/old |
--dir-new |
Directory for newer revision files | /home/user/temp/compare/new |
--log-dir |
Directory to save logs | (not set) |
--rev-old |
Older git revision | HEAD^ |
--rev-new |
Newer git revision | HEAD |
--log-level |
Logging level (debug, info, etc.) |
debug |
- Compare the last commit with the current state:
python git_meld_diff.py
- Compare two specific revisions:
python git_meld_diff.py --rev-old abc123 --rev-new def456
- Specify a custom Meld path and log directory:
python git_meld_diff.py --meld-exec /usr/bin/meld --log-dir /tmp/logs
- Parses command-line arguments.
- Identifies changed files between two Git revisions.
- Extracts file contents for each revision into separate directories.
- Launches Meld to visually compare the directories.
- Meld not found: Ensure Meld is installed and the path is correct.
- logger.py missing: Make sure
logger.pyis present in the script directory. - Permission issues: Run the script with appropriate permissions to create directories and files.
[alias]
s = status
b = branch
bn = rev-parse --abrev-ref HEAD
### top n commits in currents branch
l = log --pretty=format:'%Cred%h%Creset %Cgreen%ad%Creset %s %C(cyan)<%an>%Creset%C(auto)%d%C(reset)' --abbrev-commit --date=format:'%Y%m%d %H:%M' -15
lt = log --graph --abbrev-commit --pretty=format:'%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(dim white)%cn <%ce>%C(reset)%C(auto)%d%C(reset)\n\t\t%C(white)%s%C(reset)' --date=format:'%Y%m%d %H:%M' -15
lg = log --pretty=format:'%Cred%h%Creset - %s %C(auto)%d%C(reset) %Cgreen(%ad) %C(cyan)<%an>%Creset' --abbrev-commit --date=short
lgt = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(auto)%d%C(reset) %C(cyan)%ad%C(reset) %C(dim white)%cn <%ce>%C(reset)\n\t\t%C(white)%s%C(reset)' --date=format:'%Y%m%d %H:%M'
# show files
sf = diff-tree --name-only -r
df = !"python /home/user/projects/utils_py/git_diff.py"This project is licensed under the GNU General Public License v3.0.
Andrii Dov. andridov@gmail.com