In my working tree I renamed a file/folder and modified its content.
How do I add (and commit) only the rename but not the new content?


Here is a similar question asked over on StackOverflow.

It goes really in-depth on the way Git tracks the name changes, file creations, and deletions. The quick and dirty answer you're looking for is below.

To quote from the top answer there:

What we do now is, first, manually put the file back under its old name, then use git mv to switch again to the new name:

$ mv new-name.txt old-name.txt
$ git mv old-name.txt new-name.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.