我读过,当在git中重命名文件时,你应该提交任何更改,执行重命名,然后暂存重命名的文件.Git将从内容中识别文件,而不是将其视为新的未跟踪文件,并保留更改历史记录.
然而,今晚这样做我最终还是回归git mv.
> $ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.html
#
Run Code Online (Sandbox Code Playgroud)
将Finder中的样式表重命名iphone.css为mobile.css
> $ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: index.html
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be …Run Code Online (Sandbox Code Playgroud) 据我所知,Git并不需要跟踪文件重命名/移动/复制操作,那么git mv的真正目的是什么?手册页不是特别描述性的......
它已经过时了吗?它是一个内部命令,不是普通用户使用的吗?
维基百科解释了自动重命名检测:
简而言之,给定修订版N中的文件,修订版N-1中的同名文件是其默认祖先.但是,当修订版N-1中没有同名文件时,Git会搜索仅存在于修订版N-1中的文件,并且与新文件非常相似.
重命名检测显然归结为类似的文件检测.这个算法记录在哪里吗?很高兴知道自动检测到哪种变换.
我正在将本地提交推送到远程git服务器并收到以下警告消息:
remote: warning: only found copies from modified paths due to too many files.
remote: warning: you may want to set your diff.renamelimit variable to at least 19824 and retry the command.
Run Code Online (Sandbox Code Playgroud)
但实际上我已经将diff.renamelimit设置为0(我认为零意味着无限制,对吧?).
$ git config --list
...
diff.renamelimit=0
Run Code Online (Sandbox Code Playgroud)
那么我该怎么做才能避免这种警告呢?谢谢.
我需要更改文件夹和文件的大小写.我尝试的第一件事是重命名文件夹,但Git没有接受更改.所以我尝试使用,git mv -f controller Controller但它说:
fatal: renaming 'application/classes/controller failed: Permission denied
我尝试过设置全局ignorecase标志:
git config --global core.ignorecase false
但它仍然无效.有些人建议将文件夹移出repo,删除,然后重新添加,但当其他人拉回购时,这个更改是否会被接收?还有什么我可以尝试的吗?
编辑:它适用于文件但不适用于文件夹.
我刚刚做了git rm file1.c以后的git status节目
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: file1.c
Untracked files:
(use "git add <file>..." to include in what will be committed)
dir/file2.c
dir/file3.c
Run Code Online (Sandbox Code Playgroud)
到目前为止一切顺利.但是,如果git add dir/file2.c我得到了
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local …Run Code Online (Sandbox Code Playgroud)