如何解决Git在重命名时考虑将签入文件视为未跟踪
在我的git项目中,一名开发人员昨天将文件名从全部大写更改为CamelCase。在他的功能分支中,并合并为大师
我拉了远程主机。现在,在执行任何本地git操作期间,git都将uppsecase(旧)中的文件消息显示为未跟踪。 该文件在提到的文件夹中处于提交状态,而我从未在本地触摸过。
我尝试过的事情
- 我尝试使用
git clean -fd
清除取消跟踪树,但仍然 同样的错误。 - 我尝试使用
git rm uupercaseFilename
,但命令失败,名称与任何文件都不匹配。 - 徒劳地尝试
git reset --hard HEAD
。 - 我没有在
git status
消息中看到 ANY 文件是nothing to commit,working tree clean
-最后,我不得不手动删除带有驼峰案例名称的新文件 - 签到我的功能分支工作正常。
但是现在,如果我在feature-x
分支中执行任何操作,则我再次遇到此错误。
我可以像上面一样通过手动删除来解决此问题。 但是想知道是否有正确的方法来处理这种情况。
下面是我运行的所有确切命令,并使用重命名的文件/项目/程序包名称
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git clean -fd
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git rm main/com/my/project/badfile//ALL_CAPS_NAME.java
fatal: pathspec 'main/com/my/project/badfile//ALL_CAPS_NAME.java' did not match any files
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git rm ALL_CAPS_NAME.java
fatal: pathspec 'ALL_CAPS_NAME.java' did not match any files
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git reset --hard HEAD
HEAD is Now at 5f2918e3fd Merge branch 'feature-Y' into 'master'
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ cd main/com/my/project/badfile/
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ ls -lrt
total 12
-rwxr-xr-x 1 gitbash 1049089 1443 Jul 29 17:44 someOtherFile.java*
drwxr-xr-x 1 gitbash 1049089 0 Aug 1 23:01 config/
-rwxr-xr-x 1 gitbash 1049089 3847 Aug 11 12:48 All_Caps_Name.java*
-rwxr-xr-x 1 gitbash 1049089 2349 Aug 11 12:48 someOtherFile2.java*
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ rm All_Caps_Name.java
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ cd -
/c/repo/myrepo/myproject
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
Switched to a new branch 'feature-x'
Branch 'feature-x' set up to track remote branch 'feature-x' from 'origin'.
解决方法
使用git的视图“重新对齐”磁盘上的内容的一个技巧是临时重命名文件:
>>model.predict(inputs)
b'Dec 15,2020 @ 17:00:00.000'
<class 'bytes'>
date,week: 2020-12-15 17:00:00 51
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-75-27307271bb51> in <module>
----> 1 model.predict(inputs)
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py in predict(self,x,batch_size,verbose,steps,callbacks,max_queue_size,workers,use_multiprocessing)
924 max_queue_size=max_queue_size,925 workers=workers,--> 926 use_multiprocessing=use_multiprocessing)
927
928 def reset_metrics(self):
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_arrays.py in predict(self,model,**kwargs)
721 verbose=verbose,722 steps=steps,--> 723 callbacks=callbacks)
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_arrays.py in model_iteration(model,inputs,targets,sample_weights,epochs,val_inputs,val_targets,val_sample_weights,shuffle,initial_epoch,steps_per_epoch,validation_steps,validation_freq,mode,validation_in_fit,prepared_feed_values_from_dataset,steps_name,**kwargs)
398 # Aggregate results.
399 if batch_index == 0:
--> 400 aggregator.create(batch_outs)
401 aggregator.aggregate(batch_outs,batch_start,batch_end)
402
~/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_utils.py in create(self,batch_outs)
332 # Fail fast rather than trying to concatenate it.
333 raise RuntimeError('Attempted to aggregate unsupported object {}.'
--> 334 .format(batch_element))
335
336 self.results[-1].create(batch_element)
RuntimeError: Attempted to aggregate unsupported object b'51'.
mv ALL_UPPERCASE foo
mv foo Camel_Case
也有一个core.ignoreCase
设置,文档指出:
内部变量,它使各种变通办法能够使Git在不区分大小写的文件系统上更好地工作,例如APFS,HFS +,FAT,NTFS等。例如,如果目录列表在Git期望“ Makefile”时找到“ makefile” ”,Git将假定它确实是同一文件,并继续将其记住为“ Makefile”。
要对其进行操作:
git
,
我花了很多时间尝试很多事情,但最后最简单的方法是使用 eclipse Git Repositories
视图切换到feature-x
分支,然后合并母版使用eclipse分支到feature-x分支。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。