添加到全局git文件后的文件仍然可见 [英] File after adding to global git file is still visible

查看:102
本文介绍了添加到全局git文件后的文件仍然可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续我以前的问题是否有可能问GIT,不显示文件?



我有一个文件,我想将其添加到全局.gitignore中,不应该在里面。 gitignore of project。

我已经将 excludesfile 路径添加到我的.gitconfig文件中。

  [user] 
name = Hesa​​m
email = MY-EMAIL-ADDRESS
[color]
ui = true
diff = true
[core]
excludesfile = /Users/admin/.gitignore_global

然后我添加了完整的文件路径,我不想在 .gitignore_global 文件中跟踪它。

  /Users/admin/Desktop/android/my-app/crashlytics.properties 

不过,当我导航到我的项目目录并输入 git status 时,我的回复是:

 >> git status 
在分支上fix_confirm_booking
未记录的文件:
(使用git add< file> ...来包含将要提交的内容)

my -app / crashlytics.properties

没有添加提交,但未跟踪的文件存在(使用git add来跟踪)

任何建议,将不胜感激。谢谢。

解决方案

我只是想通了。不幸的是,Git不依赖于完整/完整的路径。只要我用相对路径(实际上不是相对路径)替换了我的完整路径,那么它就起作用了。



我做了什么,我将 .gitignore_global 内容替换为:


/Users/admin/Desktop/android/my-app/crashlytics.properties



my-app / crashlytics.properties



continue from my previous question Is it possible to ask GIT, don't show a file?

I have a file that I want to add it to global .gitignore that shouldn't be inside .gitignore of project.

I have added excludesfile path into my .gitconfig file

[user]
    name = Hesam
    email = MY-EMAIL-ADDRESS
[color]
    ui = true
    diff = true
[core]
    excludesfile = /Users/admin/.gitignore_global

Then I added full path to the file that I don't want to track it in .gitignore_global file.

/Users/admin/Desktop/android/my-app/crashlytics.properties

Still, when I navigate to my project directory and enter git status my response is:

>> git status
On branch fix_confirm_booking
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    my-app/crashlytics.properties

nothing added to commit but untracked files present (use "git add" to track)

Any suggestion would be appreciated. Thanks.

解决方案

I just figured it out. Unfortunately Git doesn't rely on full/complete path. As soon as I replaced my full path with relative (actually is not relative) path then it worked.

What I did, I replaced my .gitignore_global contents from:

/Users/admin/Desktop/android/my-app/crashlytics.properties

to

my-app/crashlytics.properties

这篇关于添加到全局git文件后的文件仍然可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆