tim*_*son 7 git github gitignore
我有一个PHP配置文件,我想在本地操作,但在git commits
我的主存储库中忽略这些更改.我有一个.gitignore
文件曾经忽略这个PHP文件但是发生了不好的事情,现在config.php
文件不再被忽略,我不记得如何重新忽略它.
我知道SO上的人说要使用,git rm --cached <filename>
但我不能为我的生活弄清楚如何不git rm...
继续删除我的config.php文件.
我想知道是否有人可以列出如何忽略我的config.php,以便我可以继续在本地编辑它,但这些更改不会添加到repo.
这是我的全部内容.gitignore
:
application/config.php
Run Code Online (Sandbox Code Playgroud)
这里是我的一些PHP代码config.php
我想保留本地而不是进入我的主仓库:
$config['base_url'] = "http://localhost/";
//$config['base_url'] = "http://mysite.com/"; // this is the code and NOT
// "http://localhost" that i'd like to keep in my repo
Run Code Online (Sandbox Code Playgroud)
这是删除我的文件:
git rm --cached application/config.php
application/config.php
文件和另一个文件(作为控件)git commit -m 'config.php shouldn't be changed'
结果:2 files changed, 1 insertions(+), 370 deletions(-)
(config.php
是370线长)
tim*_*son 10
我解决了自己的问题.我其实需要这个:
git update-index --assume-unchanged <filename>
假设在我的问题中如上所述指定了.gitignore和config.php文件,这里是完整的工作流程:
git update-index --assume-unchanged application/config.php
git add -A
git commit -m 'now config.php will be ignored'
git push origin master
现在http://localhost
将保留在我的本地repo副本http://my-site.com
的config.php中,并将保存在我的主仓库中的config.php中.
归档时间: |
|
查看次数: |
2915 次 |
最近记录: |