Search code examples
gitcommitgit-loggit-mv

No commit history with git log --follow after renaming folder with different case


I've had troubles after renaming a folder Draft to draft on macOS.

The commands are below:

cd path/to/Draft
cd ..
git checkout main

git config core.ignorecase false

# git mv Draft draft # Failed with 'Invalid argument'
git mv Draft tmp && git mv tmp draft
git add -u draft
git commit -m "[fix] case in folder Draft"

which finally shows

 6 files changed, 0 insertions(+), 0 deletions(-)
 rename app/api/{Draft => draft}/change-draft.ts (100%)
 rename app/api/{Draft => draft}/create-project-draft.ts (100%)
 rename app/api/{Draft => draft}/create-user-draft.ts (100%)
 rename app/api/{Draft => draft}/get-draft.ts (100%)
 rename app/api/{Draft => draft}/get-project-drafts.ts (100%)
 rename app/api/{Draft => draft}/get-user-drafts.ts (100%)

But as I run git log --follow draft, it just shows the case fix commit. While git log --follow Draft shows all commits.

The scene is same in repo in github, which only shows 1 commit by me (6 rename operation are well shown, but other commits are lost)

Only the Blame can help me track the draft history (It seems no effects for Blame)

So, can I rename Draft to draft with complete commit history in draft? How or why can't?

After Commit commit

Commit Detail concrete commit


Solution

  • The documentation says that the option --follow works only for a single file.

    --follow Continue listing the history of a file beyond renames (works only for a single file).

    In your case, instead, you're supplying an entire folder.

    If you want to see the commit history beyond the rename, you need to supply one of the files contained in draft.

    git log --follow draft/my_file.js