我用mongodb数据库建立了一个简单的nodejs express服务器。 不幸的是,在尝试将代码同步到github之前,我忘了添加一个正确的gitignore。
push命令失败,因为我的数据库的日志太大了。
现在我添加了一个仅包含
行的.gitignore文件data
因为那是存储数据库的地方。
我在shell中运行了这段代码(Ubuntu 14.10):
git rm -r --cached
git add .
git commit -m "untracked database"
git push --set-upstream origin master
令人惊讶的是,推动仍然失败:
文件数据/ journal / j._0是1024mb;这超过了githubs文件大小限制为100mb
所以gitignore没有用?
git rm -r --cached
git add .gitignore
git add *
git commit -m "untracked database 2"
git push --set-upstream origin master
相同错误
git rm -r --cached data/
致命:pathspec'data /'与任何文件都不匹配
git rm -r data/
致命:pathspec'data /'与任何文件都不匹配
git rm -r --cached data/**
致命:pathspec'data / journal /'与任何文件都不匹配
对我来说,git似乎没有跟踪这些文件。为什么要尝试同步它们?
更新
我将.gitignore的内容更改为
data/
同样的问题。
然后我试了
data/**
错误仍然存在。
cat .gitignore
data/
git rm -r --cached
git add .
git add *
The following paths are ignored by one of your .gitignore files:
data
Use -f if you really want to add them.
fatal: no files added
git commit -m "untracked data"
On branch master
nothing to commit, working directory clean
ls
app.js app.ts data/ node_modules/ public/ views/
app.js.map bin/ definitions/ package.json routes/
git push --set-upstream origin master
Username for 'https://github.com': lhk
Password for 'https://lhk@github.com':
Counting objects: 1486, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1342/1342), done.
Writing objects: 100% (1486/1486), 3.71 MiB | 561.00 KiB/s, done.
Total 1486 (delta 306), reused 2 (delta 0)
remote: warning: File data/krauterkontor.0 is 64.00 MB; this is larger than
Github's recommended maximum file size of 50 MB
remote: warning: File data/local.0 is 64.00 MB; this is larger than GitHub's
recommended maximum file size of 50 MB
remote: error: GH001: Large files detected.
remote: error: Trace: 3082472065ce69786a2ff7d409d1cb92
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File data/journal/j._0 is 1024.00 MB; this exceeds GitHub's file size
limit of 100 MB
remote: error: File data/journal/prealloc.1 is 1024.00 MB; this exceeds GitHub's file
size limit of 100 MB
To https://github.com/lhk/krauterkontor
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/lhk/******'
那里发生了什么?首先,它不会添加数据/,然后它会尝试推送它。
git rm -r data/
fatal: pathspec 'data/' did not match any files
更新:
我真的不知道如何解决这个问题,因为它是第一次提交到空存储库,我选择了一个丑陋的解决方案。我刚刚重命名了文件夹,再次克隆了repo,将所有代码复制到新文件夹,添加了正确的.gitignore并推送了提交。这很好。
不幸的是我再也无法重现这个问题了,这个问题已经不再有效了。
答案 0 :(得分:2)
您的.gitignore
必须包含data/
,而不是data
:
data
会忽略名为data
的所有文件,data/
会忽略文件夹 data
的内容。