Reputation: 4182
I got 100 of images which I needed to rename from .JPG to .jpg. I already wrote a gulp task and renamed them all. Now Git is not recognizing the change.
I found this on single files: I change the capitalization of a directory and Git doesn't seem to pick up on it
But I don't want to do this on each image by hand is it possible to use s.th. like this
git mv **/*/.JPG **/*.temp
git mv **/*/.temp **/*.jpg
The images are all in diff. folders! E.g. src/a, src/a/b src/b ...
Upvotes: 1
Views: 289
Reputation: 4182
This works:
for file in $(git ls-files '*.JPG');
do git mv -f $file $(echo $file |sed 's/\.JPG/\.jpg/'); done
git ls-files
lists all files => '*.JPG'
filtersgit mv -f
moves the files (-f = force, which is required)$file
returns the original filename$(echo $file |sed 's/\.JPG/\.jpg/')
is the new filenameHelpful threads:
git rename many files and folders
How to rename large number of files
Upvotes: 1
Reputation: 876
for line in $(find -type f -name '*.JPG'
| sed 's@\(.*\)\.JPG@\1.JPG \1.jpg/')
do
git mv $line
done
If you already renamed your files you just need to git add
them.
Since they haven't changed git
will notice they all have the the same blob
object and setup the renaming. If you don't have any other unknown or
changed files in your git working dir, one possible way is:
for path in $(git status --porcelain | sed 's/.. //')
do
git add "$l"
done
Upvotes: 1
Reputation: 113
There is a small change to the answer given by @jvdm to make the first code snippet work.
for line in $(find -type f -name '*.JPG'
| sed 's@\(.*\)\.JPG@\1.JPG \1.jpg/')
do
git mv $line
done
Upvotes: 1