Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在不使用.gitignore的情况下保留文件的本地版本?_Git_Git Svn_Gitignore - Fatal编程技术网

如何在不使用.gitignore的情况下保留文件的本地版本?

如何在不使用.gitignore的情况下保留文件的本地版本?,git,git-svn,gitignore,Git,Git Svn,Gitignore,不想更改.gitignore,因为其他人想要repo中的文件。但我有我自己的副本,我想用 我编辑了.git/info/exclude,并添加了以下内容: /Gemfile /Gemfile.lock /config/database.yml /spec/spec_helper.rb 这似乎没什么用git状态仍显示: # Changes not staged for commit: # (use "git add <file>..." to update what will be

不想更改.gitignore,因为其他人想要repo中的文件。但我有我自己的副本,我想用

我编辑了
.git/info/exclude
,并添加了以下内容:

/Gemfile
/Gemfile.lock
/config/database.yml
/spec/spec_helper.rb
这似乎没什么用<代码>git状态仍显示:

# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Gemfile
#       modified:   Gemfile.lock
#       modified:   config/database.yml
#       modified:   spec/spec_helper.rb
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#
#修改:Gemfile
#修改:Gemfile.lock
#修改:config/database.yml
#修改:spec/spec_helper.rb

在不使用.gitignore的情况下保存我的本地版本文件的最佳方法是什么?

您已经用一个前导的
/
启动了所有文件。我认为,如果你将其移除,一切都会很好:

Gemfile
Gemfile.lock
config/database.yml
spec/spec_helper.rb

.gitignore
.git/info/exclude
仅适用于存储库中尚未存在的文件。如果文件在存储库中,您不能要求Git忽略它们


您可以在本地维护这些更改,或者作为一个分支与主控上的传入工作合并,或者作为一组更改在主控上重新设置基础。但是,这两种方法都有点不方便。

我在我的机器上使用了一个全局忽略文件,它也被使用了-因此,通过这种方式,您可以使用基于项目的.gitignore文件+您机器本地的全局设置

我在~/.gitconfig中有这个

[core]
   excludesfile = /home/adrian/.gitignore

您可能会调用
git update index——假设[文件名]
未更改,或者如果有一堆文件,只需对.gitignore执行此操作,并根据需要修改ignore文件即可

来自(我的):

当“假定未更改”位处于启用状态时,git将停止检查工作树文件是否存在可能的修改,因此您需要手动取消设置该位,以便在更改工作树文件时通知git。 …
此选项还可用作粗略文件级机制,以忽略跟踪文件中未提交的更改(类似于.gitignore对未跟踪文件所做的更改)


实际上,我在发帖之前就试过了。同样的结果。你不能要求Git忽略存储库中已经存在的文件。是的,这就是我在前面的评论中所说的。你不能要求Git忽略存储库中已经存在的文件。这是你可以使用的吗?