I have changed a few files name by de-capitalize the first letter, as in Name.jpg
to name.jpg
. Git does not recognize this changes and I had to delete the files and upload them again. Is there a way that Git can be case-sensitive when checking for changes in file names? I have not made any changes to the file itself.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
I tried the following solutions from the other answers and they didn't work:
git mv filename
git rm -f filename
If your repository is hosted on GitHub like mine is, you can rename the file on origin (GitHub.com) and force the file rename in a top-down manner. Here's what I did:
branchname
branch" radio button is selectedI've faced this issue several times on MacOS. Git is case sensitive but Mac is only case preserving.
Someone commit a file:
Foobar.java
and after a few days decides to rename it toFooBar.java
. When you pull the latest code it fails withThe following untracked working tree files would be overwritten by checkout...
The only reliable way that I've seen that fixes this is:
git rm Foobar.java
git commit -m 'TEMP COMMIT!!'
git rebase --continue
git rebase -i HEAD~2
anddrop
theTEMP COMMIT!!
FooBar.java
1) rename file
Name.jpg
toname1.jpg
2) commit removed file
Name.jpg
3) rename file
name1.jpg
toname.jpg
4) ammend added file
name.jpg
to previous commitIt can sometimes be useful to temporarily change Git's case sensitivity. Two possible methods:-
Method 1:
git -c core.ignorecase=true checkout mybranch
to turn off case-sensitivity for a singlecheckout
command. Or more generally:git -c core.ignorecase=
<<true or false>>
<<command>>
. (Credit to VonC for suggesting this in the comments.)Method 2:
To change the setting for longer (e.g. if multiple commands need to be run before changing it back):
git config core.ignorecase
(this returns the current setting, e.g.false
).git config core.ignorecase
<<true or false>>
- set the desired new setting.git config core.ignorecase
<<false or true>>
- set config value back to its previous setting.When you've done a lot of file renaming and some of it are just a change of casing, it's hard to remember which is which. manually "git moving" the file can be quite some work. So what I would do during my filename change tasks are:
This will fix all the case issues without trying to figure out which files or folders you renamed.