0

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?

2 Answers 2

0

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
0

Copy the modified renamed file to a temporary file, then git reset --hard to undo all your changes.

Then do just the rename via git mv ... and commit that change. Then copy back the changes and remove the temporary file.

In the next step you can add your changes to the renamed file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .