Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Put somewhere in your $PATH, and chmod +x git-rename
# On a branch with files already moved and changed locally but not in git.
# Usage:
# git rename existing-checked-in-filename new-and-changed-filename
#!/usr/bin/env bash
mv $TO ${TO}-1
git co $FROM
git mv $FROM $TO
git add $TO
git ci -m "Moved $FROM to $TO"
mv ${TO}-1 $TO
git add $TO
git ci -m "Updates to $TO"

This comment has been minimized.

Copy link
Owner Author

@IanVaughan IanVaughan commented May 6, 2020

Changes a sandbox from this :

$ git status
On branch change-namespace
Changes not staged for commit:
       deleted:    app/lib/old-namespace/filename.rb

Untracked files:

to this:

$ git log
* 0c9927db - (HEAD -> change-namespace) Updates to app/lib/new-namespace/filename.rb
* dde55f23 - Moved app/lib/old-namespace/filename.rb to app/lib/new-namespace/filename.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment