phi*_*bar 5 git .htaccess commit
我试图忽略除www目录中的.htaccess文件之外的所有文件.
我有这个:
# Ignore everything in this directory
*
# Except this file
!.gitignore
!/www/.htaccess
Run Code Online (Sandbox Code Playgroud)
我也试过这个:
# Ignore everything in this directory
*
# Except this file
!.gitignore
!www/.htaccess
Run Code Online (Sandbox Code Playgroud)
当我运行时,git status我没有看到.htaccess是一个添加的文件.我尝试过提交.gitignore文件.依然没有.我错过了一些明显的东西,不是吗?
更新
我也试过这些:
# Ignore everything in this directory
*
*/\.htaccess
# Except these files
!.gitignore
!www/\.htaccess
Run Code Online (Sandbox Code Playgroud)
和
# Ignore everything in this directory
*
*/.htaccess
# Except these files
!.gitignore
!www/.htaccess
Run Code Online (Sandbox Code Playgroud)
我在我的机器上尝试了一些示例步骤,尝试它们并检查它们是否适合您.
cd ~/Desktop/test
mkdir www && touch .gitignore www/.gitkeep www/.htaccess www/file1 www/file2
git init && git add www/.gitkeep && git commit -m "gitkeep to make www trackable"
Run Code Online (Sandbox Code Playgroud)
git status现在做的将告诉你
.gitignore
www/.htaccess
www/file1
www/file2
Run Code Online (Sandbox Code Playgroud)
现在,在.gitignore文件中,添加以下两个条目
www/*
!www/.htaccess
Run Code Online (Sandbox Code Playgroud)
做一个git status现在显示
.gitignore
www/.htaccess
Run Code Online (Sandbox Code Playgroud)
您现在可以使用git add .并提交这两个文件.
此外,一旦您确信所述命令有效,您可以删除www/.gitkeep我的示例中的I generate(它被添加为www可跟踪,git不是版本文件夹)并添加www/.htaccess以减少冗余文件的开销.
| 归档时间: |
|
| 查看次数: |
11812 次 |
| 最近记录: |