Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

a utility on top of git for project-wide search-and-replace that includes filenames too

Project Description


git-search-replace is a small utility on top of plain git for performing project-wide search-and-replace only on git-controlled files. It applies its searches to filenames as well as their content. The underlying syntax for the search regex is Python’s.

It is designed to be a bit more instructive to the developer, compared to hackish bash scripts around sed.

Key features are:

  • By default, only act as grep to show what is going to change.
  • Dry run mode ‘–diff’ shows a unidiff of the changes that the search-and-replace would do, so that the developer can review for correctness. No working directory files are modified.
  • Fix mode ‘–fix’ performs the actual changes and associated ‘git mv’.


Usage: gsr [options] (FROM-SEPARATOR-TO…)

-h, --help show this help message and exit
-s STRING, --separator=STRING
 The separator string which separates FROM regex and TO expression
-f, --fix Perform changes in-place
-d, --diff Use ‘diff’ util to show differences

The expressions are tuples in the form of FROM-SEPARATOR-TO, with SEPARATOR defaults to ‘///’.


Shell escaping needs to be taken into consideration. The examples below should work with the major UNIX shells.

gsr old_name///new_name –diff

This shows a diff that represents the replacement of ‘old_name’ with ‘new_name’.

gsr \bold_name\b///new_name –fix

This uses Python regex expression b for matching at word boundaries for whole identifiers. This invocation will perform changes in-place because of ‘–fix’.

gsr ‘things with space///with other stuff’ –diff

Note that shells properly de-escape the commas from the expression above.

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
git-search-replace-1.0.2.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Mar 13, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting