标题可能对事情有点奇怪的解释,所以我将在这里详细介绍。
我已经为网站设置了git repo通过github,所以我们所有人都可以在自己的计算机上编辑,然后将更改推送到网络服务器。然后我在我的网站上有一个拉片脚本,每隔几分钟git pull --rebase
,如果回购中有变化。
现在,我不希望在github上拥有数据库的用户名和密码,所以我想在服务器上本地拥有一个.htaccess文件,该文件包含用户名和密码,而不是在php文件中。所以我在本地创建了一个.htaccess文件,并在gitignore和gitattributes中添加了.htaccess,但每当我执行git pull --rebase
时,都会删除对.htaccess文件的更新。如果我git rm .htaccess
和git status
它说.htaccess已被删除,我必须将文件推送到repo,即使repo没有任何.htaccess文件。而且我无法推送,因为repo的服务器版本是只读的。
有什么想法吗?
使用.gitignore文件进行更新: ################# ## Eclipse #################
*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover
## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
# Visual Studio profiler
*.psess
*.vsp
# ReSharper is a .NET coding add-in
_ReSharper*
# Installshield output folder
[Ee]xpress
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish
# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
############
## Windows
############
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
#############
## Python
#############
*.py[co]
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
# Mac crap
.DS_Store
#################
## Project specific
#################
# Ignore htcaccess so so pwd is not public
.htaccess
# Ignore the pull script because this is only for the server
pull.php
答案 0 :(得分:0)
我设法从stackoverflow上的这篇文章中找到了一个解决方案(我希望):Ignore files that have already been committed to a Git repository
为我做的那条线是:git update-index --assume-unchanged <file>
答案 1 :(得分:0)
Github 只是不支持上传 htacess 文件,但是你仍然可以在 github 中手动添加 htaccess 文件
1.转到要添加 htacess 文件的存储库
2.点击Add file
-Create new file
3.打开文件 .htaccess 并复制 htaccess 文件的所有内容并将其粘贴到“编辑新文件”部分。您所要做的就是输入文件名 .htaccess
,根据需要输入提交名称,然后提交