Topic 6.6
Handy Power Tools: grep, shortlog, range-diff, notes, archive & bundle
In one line
A handful of lesser-known commands save real time. git grep searches tracked files (or any old version) very fast. git shortlog summarises commits by author, which is great for release notes. git range-diff compares two versions of a rebased branch, so reviewers see what changed between pushes. git notes attaches notes to commits without changing them. git archive exports a clean snapshot without .git, and git bundle packs a repository into a single file for offline transfer.
Think of it like this
The extra tools in a kitchen drawer: a zester, a garlic press, a thermometer. You don't use them every day, but when you need one, nothing else does the job as well.
Words you'll meet
New words in this topic, in plain English. Come back here whenever one feels fuzzy.
- git grep
- Search for text in tracked files of the working tree or any commit.
- git shortlog
- Summarise commits grouped by author.
- git range-diff
- Compare two ranges of commits, typically two versions of a rebased branch.
- git notes
- Extra text attached to commits, stored separately so commit hashes don't change.
- git archive
- Create a tar or zip of a commit's files without Git history.
- git bundle
- Pack refs and objects into a single file that can be cloned or fetched from.
Step by step
01Searching the code, now and then
Arjun needs every use of the old deliveryFee helper before deleting it. git grep searches only tracked files, so it skips node_modules and build output. Searching a tag shows whether the old release used it.
02Who did what in this release
For the v1.7.0 release notes, Priya lists commits by author since the previous tag.
03What changed between two pushes of a PR?
Priya rebased and tidied her PR after review (Topic 2.4) and force-pushed. Arjun doesn't want to re-read everything. range-diff compares the old series with the new one: two commits unchanged, one modified (with the exact change), and the typo commit gone.
04Notes, archives, and bundles
After a deploy, CI attaches a note to the commit (the commit hash stays the same). For a partner who needs the source of v1.7.0 without history, Priya exports an archive. For a client site with no internet, a bundle carries the whole repository on a USB stick.
Break it on purpose
Errors are the best teachers. Make each change, read the error, guess what went wrong, then reveal the answer.
Break #1
git grep misses a new file
Neha creates src/offers.js, which calls deliveryFee(, but hasn't run git add yet. Arjun searches with git grep.
Myth vs fact
Myth
Notes and archives change the repository's history.
Fact
Notes live in a separate ref, so commit hashes are unchanged. Archive only reads a commit and writes files outside the repo.
Pro corner
Extra depth for experienced readers. New to this? Skip it for now and come back later.
- ▸
git log -L :cartTotalPaise:src/checkout/cart.jsshows the history of one function: every commit that changed it, with only that function's diff. Combined withgit grepandblame, it answers 'how did this code get like this?' very quickly.
Remember this
- 1
git grep "text"searches tracked files, faster than plain grep and skippingnode_modules. Add a commit or tag to search an old version:git grep -n couponCode v1.6.0. - 2
git shortlog -sn v1.6.2..v1.7.0counts commits per author in a release. Without-sit lists each author's commit subjects, a quick start for release notes. - 3
git range-diffcompares two versions of the same series of commits, for example a PR before and after a rebase. It shows which commits are unchanged (=), modified (!), added, or dropped. - 4
git notes add -m "…" <commit>attaches extra information (such as 'deployed to prod 18:30') without changing the commit's hash. Notes live in their own ref and must be pushed explicitly. - 5
git archive --format=tar.gz -o app.tar.gz v1.7.0exports exactly the files of that version, with no history and no.git, ready to ship or attach to a release. - 6
git bundle create repo.bundle --allpacks history into one file that can be copied by USB or to a machine with no network access, then cloned or fetched from like a remote.
Explain it without notes
When is git range-diff useful?
How is git archive different from zipping the project folder?
Practice
Find every use of a function in the current code and in an old tag.
Compare two versions of a rebased branch with range-diff.
Trade-offs
- ↔
These tools are fast and built in, with no extra installs. Notes and bundles are less familiar to teammates and hosting services (GitHub doesn't display notes), so document when you use them.
Done when you can
I search with git grep, including old versions.
I can summarise a release with shortlog.
I can review a rebased PR with range-diff.
I know when to use notes, archive, and bundle.