.gitignore不会忽略文件 [英] .gitignore doesn't ignore files

查看:127
本文介绍了.gitignore不会忽略文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 .gitignore 文件被忽略,应该忽略的文件仍然可见。

  user @ host〜/ workdir%git status 
#在分支主机上
#已更改但未更新:
#(使用git add< file> ...更新提交)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#修改:.htaccess
#修改:application / controllers / statistics.php

没有更改添加到提交中(使用git add和/或git commit -a)
user @ host〜/ workdir%cat .gitignore
.htaccess
application / config / config.php
application / config / database.php
user @ host〜/ workdir%

这些文件在版本控制中,但是我不想推送明智的更改。 git rm ... 不是一个选项,因为这些文件应该位于版本控制1中(以及文件中的其他设置)。我只是不想推动我对这些文件的修改。 解决方案

忽略git中的文件并不意味着你不会推动它们。这意味着你不会版本控制它们。如果你不想推,那么我建议你创建一个本地分支,它将包含本地机器的东西,然后将必要的更改合并到你将推送到远程的分支。



我认为你已经添加编辑你的文件,现在正试图忽略它们。

My .gitignore file gets ignored and the files which should be ignored are still visible.

user@host ~/workdir % git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   .htaccess
#       modified:   application/controllers/statistics.php
#
no changes added to commit (use "git add" and/or "git commit -a")
user@host ~/workdir % cat .gitignore
.htaccess
application/config/config.php
application/config/database.php
user@host ~/workdir %

The files are in version control, but with sensible changes I dont want to push. git rm ... is not an option because the files should be in version controll (with other settings in the files). I just dont want to push my changes on this files.

解决方案

Ignoring files in git doesn't mean that you won't push them. It means that you won't version control them. If you don't want to push then, I suggest you create a local branch which will contain stuff for the local machine and then merge necessary changes to a branch which you'll push to remote.

I think you've already added your files and are now trying to ignore them.

这篇关于.gitignore不会忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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