RenegadeAndy
RenegadeAndy

Reputation: 5690

Git change filename has caused it to be not tracked

I had a file previously named Favourite.rb - and I renamed it in my code editor to favourite.rb I pushed my changes and notice in bitbucket, that the file is still "Favourite.rb". I am running mac osx - and have heard that it is not case sensitive file system. So I tried renaming the file entirely - to force git to pickup the change. Still not working. I tried to add the file, and also tried git mv where git says it is not under version control...but I have added it?! So what is going on!

Please help:

Andys-MacBook-Pro:models andy$ ls
age_collection.rb   category.rb     favourite.rb        mention.rb      user.rb
age_range.rb        concerns        follow.rb       session.rb      visit.rb
ahoy            event.rb        invitation.rb       sub_category.rb
attendee.rb     event_category.rb   like.rb         test.rb
Andys-MacBook-Pro:models andy$ git add .
Andys-MacBook-Pro:models andy$ git commit -am "all up to date"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Andys-MacBook-Pro:models andy$ git mv favourite.rb foo.rb
fatal: not under version control, source=app/models/favourite.rb, destination=app/models/foo.rb
Andys-MacBook-Pro:models andy$ 

Upvotes: 0

Views: 607

Answers (2)

David Deutsch
David Deutsch

Reputation: 19035

Rename it back to have the original casing (mv favourite.rb Favourite.rb), then git mv it to foo.txt, and then git mv it to have the casing you desire:

git mv Favourite.rb foo.rb
git mv foo.rb favourite.rb

Upvotes: -1

Peter Giacomo Lombardo
Peter Giacomo Lombardo

Reputation: 712

When installing OSX, you have the choice of formatting your drive as case-sensitive or case insensitive. It sounds like yours is case-sensitive (capitalization matters).

The thing with git is that to do a file rename, you have to do it with git. If you rename the file through your text editor, git will not know about it and think the original file was just deleted and it will see the renamed file as an "unknown".

Run git status and favourite.rb should show up under "untracked files". If this is the case, rename it back to Favourite.rb (mv favourite.rb Favourite.rb) and then do the original file rename through git: git mv Favourite.rb favourite.rb

git status again will show you the changes. commit and push and all should look OK on bitbucket.

Upvotes: 2

Related Questions