Reputation: 17532
Referencing the screenshot above, I changed the name of the lowest-level folder in the tree. For example, I changed "Chips" to "chips." Oddly, Git refuses to recognize the following command when I try to add it to the commit:
git add public/images/chips/
The only way I can get it to add the file to the commit is by adding an actual file in the subfolder.
Any ideas how to handle?
Upvotes: 5
Views: 1302
Reputation: 1326782
Note that, from March 15th, 2013, you can move or rename a file directly from GitHub.
That means, in your case, you could rename folders on GitHub, then clone your repo in a fresh local repo, with the new names for said folders.
You can also move files to entirely new locations using just the filename field.
To navigate down into a folder, just type the name of the folder you want to move the file into followed by/
.
The folder can be one that’s already part of your repository, or it can even be a brand-new folder that doesn’t exist yet!
Upvotes: 1
Reputation: 5930
This is probably only an issue when working with an OS that has case-insensitive filesystems, like OSX and Windows. You should do the rename on a unix system / case-sensitive filesystem - it will work there with either way (git mv
or first rename, then git add
- it will detect the move).
Then back on your case-insensitive system you'll probably get conflicts during the pull. It may help to manually rename there and try the pull again - git should merge these changes properly then (because there're actually none if the commit changed nothing else within that directory).
You can also get around this by some advanced git and rename trickery: Rename to chips-tmp
first, commit, then rename to chips
, amend your previous commit. Only then push to your upstream repositoy.
Look here:
Upvotes: 1
Reputation: 5300
Try git add -A
. This will detect renames/deletes that weren't done through git mv
/git rm
.
Upvotes: 0
Reputation: 700
How did you rename the folders? I always move / rename files in my repository using git mv
(git help mv
). Try mv
ing the files/folders back to what git knew they looked like, then use git's version of move instead?
Upvotes: 0
Reputation: 20667
In general when changing file or directory names, you'll want to use the following:
git mv oldfile newfile
This will tell git to actually add the changes so that you can commit them. So, try manually changing it back with
mv chips Chips
and then run
git mv Chips chips
Upvotes: 3