bitbucket .gitignore .DS_Store也忽略了封闭目录

时间:2014-10-11 01:17:52

标签: git bitbucket gitignore

Bitbucket .gitignore与DS_Store也会忽略封闭目录以及该目录中的所有其他文件。 假设我的.gitignore中有.DS_Store。 我将文件更改并添加到目录中。 由于.DS_Store文件已创建,因此将忽略整个目录和其他文件。 我想提交其他更改,但bitbucket忽略了它们!

如何配置这个.DS_Store文件不在我的bitbucket中?

2 个答案:

答案 0 :(得分:0)

如果您包含.gitignore文件以及您尝试添加的文件,将会有所帮助。

根据您想要完成的任务,以下其中一项应该有效。

如果您希望文件保持忽略但以任何方式添加它们,请使用-f选项(-f / - force 允许添加否则忽略的文件。)到git add

git add -f <some_file>

如果您想取消签名,则需要重新配置.gitignore。一种方式可能看起来像

.gitignore 
.DS_Store
!.DS_Store/file_to_be_added

您可以通过搜索SO找到特定.gitignores和howtos的各种示例。

答案 1 :(得分:0)

(这不是一个真正的答案,但想放置代码的空间)

为了理智,请尝试在控制台/ shell上的新/空目录中执行此操作:

git init
touch .DS_Store
touch otherFile.txt
echo .DS_Store> .gitignore
git add .gitignore
git status

结果应该

On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   .gitignore

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        otherFile.txt
相关问题