相关疑难解决方法(0)

.gitignore忽略所有文件,然后递归地允许*.foo

已经有几个类似的问题,但没有一个答案对我有用.

我想忽略我的存储库下面的文件夹中的所有内容,除了带有*.foo的文件

(如果有人想知道如何证明这一点 - 我实际上正在为我的所有"逻辑"项目 - mac上的音乐软件 - 创建一个git存储库 - 但我只想存储实际的项目文件*.logic)

我要拼出来,所以我们都在同一个盘子里.这是我从头开始做的事情:

建立:

mkdir temp
cd temp
mkdir testdir
cd testdir
touch include.foo
touch dontinclude.bad
cd..
git init
touch .gitignore
Run Code Online (Sandbox Code Playgroud)

将其粘贴到.gitignore中

# Ignore all
/*

# But not these files...
!.gitignore
!*.foo
Run Code Online (Sandbox Code Playgroud)

git状态

唯一没有跟踪的文件是.gitignore

如果我输入'git add'. - 没有变化,只看到.gitignore,我的2个文件被忽略.

为什么这不起作用,你怎么能改变上面的程序使它工作?

这是我从中获取.gitignore文件的极其相似的问题.我正在使用git --version 1.7.7(也试过1.7.3) - .gitignore忽略所有文件,然后递归地允许某种类型的文件

git

55
推荐指数
1
解决办法
2万
查看次数

无法理解gitignore如何忽略这些文件夹

我想为我的Magento项目创建存储库.根目录中有很多文件夹和文件,我只更改一个文件夹的时间:app/code/local /

我想忽略的其他一切.但是......不能.我的.gitignore文件:

*
!app/code/local/
!app/code/local/*
Run Code Online (Sandbox Code Playgroud)

然后,当我尝试将文件夹添加到repo时,我收到一个错误:

git add app/code/local/Mds/

The following paths are ignored by one of your .gitignore files:
app
Use -f if you really want to add them.
fatal: no files added
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙吗?

git gitignore

12
推荐指数
1
解决办法
3779
查看次数

标签 统计

git ×2

gitignore ×1