Command Palette

Search for a command to run...

Hectal
PHASE 6Advanced ~16 min· topic 6 of 6

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.

0/6 · 0%

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.

terminal
$ git grep -n "deliveryFee("
git grep -c "deliveryFee(" v1.6.0
── expected output ──
src/checkout/cart.js:22: const fee = deliveryFee(cart);
src/riders/eta.js:9: if (deliveryFee(order) === 0) priority += 1;
v1.6.0:src/cart.js:3
v1.6.0:src/riders/eta.js:1

02Who did what in this release

For the v1.7.0 release notes, Priya lists commits by author since the previous tag.

terminal
$ git shortlog -sn v1.6.2..v1.7.0
git shortlog v1.6.2..v1.7.0 --no-merges | head -4
── expected output ──
14 Priya Sharma
9 Arjun Mehta
2 Neha Rao
Arjun Mehta (9):
Filter rider orders by city
Hide offline riders from dispatch
Add ₹5 packaging charge per item

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.

terminal
$ git range-diff main 9f8e7d6 feature/coupons
── expected output ──
1: 4d5e6f7 = 1: 7b8c9d0 Add coupon model
2: 6a1b2c3 ! 2: 0c1d2e3 Validate coupon expiry
@@ src/coupons.js
-+ if (coupon.expiresAt < now) return 0;
++ if (coupon.expiresAt <= now) return 0;
3: b5a4c3d = 3: 5e6f7a9 Validate minimum order
4: 9f8e7d6 < -: ------- fix typo
9f8e7d6 is the old tip (from the reflog or the PR page). The arguments are base, old tip, new tip.
What changed between two pushes of a PR?diagram
Rendering diagram…

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.

terminal
$ git notes add -m "deployed to prod 2026-10-01 18:30 IST" 0e9d8c7
git log -1 --format='%h %s%n%N' 0e9d8c7
git archive --format=tar.gz --prefix=tiffin-1.7.0/ -o tiffin-1.7.0.tar.gz v1.7.0
git bundle create tiffin.bundle --all
git clone tiffin.bundle tiffin-offline
── expected output ──
0e9d8c7 Merge branch 'feature/coupons'
deployed to prod 2026-10-01 18:30 IST
 
Enumerating objects: 13360, done.
Total 13360 (delta 6120), reused 13360 (delta 6120), pack-reused 0
Cloning into 'tiffin-offline'...
Receiving objects: 100% (13360/13360), 33.70 MiB | 98.10 MiB/s, done.
Push notes with `git push origin refs/notes/*`. They aren't pushed by default.

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.

terminal
$ git grep -l "deliveryFee("
ls src/offers.js
── what you'll see ──
src/checkout/cart.js
src/riders/eta.js
src/offers.js
The new file exists but isn't in the search results.

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.js shows the history of one function: every commit that changed it, with only that function's diff. Combined with git grep and blame, it answers 'how did this code get like this?' very quickly.

Remember this

  1. 1

    git grep "text" searches tracked files, faster than plain grep and skipping node_modules. Add a commit or tag to search an old version: git grep -n couponCode v1.6.0.

  2. 2

    git shortlog -sn v1.6.2..v1.7.0 counts commits per author in a release. Without -s it lists each author's commit subjects, a quick start for release notes.

  3. 3

    git range-diff compares 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. 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. 5

    git archive --format=tar.gz -o app.tar.gz v1.7.0 exports exactly the files of that version, with no history and no .git, ready to ship or attach to a release.

  6. 6

    git bundle create repo.bundle --all packs 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

01

When is git range-diff useful?

02

How is git archive different from zipping the project folder?

Practice

01

Find every use of a function in the current code and in an old tag.

02

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.