【问题标题】:why config folder is not pushed?为什么不推送配置文件夹?
【发布时间】:2012-07-30 14:33:34
【问题描述】:

虽然我确信在推送之前我已将所有文件和文件夹添加并提交到我的本地 git 存储库中

我不知道为什么远程仓库缺少配置文件夹

我不知道如何调查这个问题,当然我没有将配置文件夹名称添加到 .gitignore 或 .slugignore ,但是,它永远不会被推送!

我做了git init,git add .git commit,然后

git push heroku master

那么,关于这个问题的想法?

编辑

当我尝试手动在配置中添加文件时,我得到:

sam@ubuntu:~/RubymineProjects/dcaclab$ cd config
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git add *
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git commit -m "config files"
# On branch master
nothing to commit (working directory clean)
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git push heroku master
Everything up-to-date
sam@ubuntu:~/RubymineProjects/dcaclab/config$

编辑 2

# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile ~/.gitignore_global

# Ignore bundler config


# Ignore the default SQLite database.
/db/*.sqlite3



# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
sam@ubuntu:~/RubymineProjects/dcaclab$ ls config/
application.rb  boot.rb  database.yml  environment.rb  environments  initializers  locales  newrelic.yml  routes.rb

编辑 3

sam@ubuntu:~/RubymineProjects/dcaclab$ ls config
application.rb  database.yml    environments  locales       routes.rb
boot.rb         environment.rb  initializers  newrelic.yml

编辑 4

sam@ubuntu:~/RubymineProjects/dcaclab$ cd config
sam@ubuntu:~/RubymineProjects/dcaclab/config$ echo 'test' > test_file
sam@ubuntu:~/RubymineProjects/dcaclab/config$ ls config
ls: cannot access config: No such file or directory
sam@ubuntu:~/RubymineProjects/dcaclab/config$ dir
application.rb  database.yml    environments  locales       routes.rb
boot.rb     environment.rb  initializers  newrelic.yml  test_file
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   test_file
nothing added to commit but untracked files present (use "git add" to track)
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git add .
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git commit -m "a file"
[master 55a0159] a file
 1 file changed, 1 insertion(+)
 create mode 100644 config/test_file
sam@ubuntu:~/RubymineProjects/dcaclab/config$ git push heroku master
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 336 bytes, done.
Total 4 (delta 2), reused 0 (delta 0)

-----> Heroku receiving push
-----> Ruby/Rack app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
       Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
       Using rake (0.9.2.2)
       Using i18n (0.6.0)
       Using multi_json (1.3.4)
       Using activesupport (3.2.3)
       Using builder (3.0.0)
       Using activemodel (3.2.3)
       Using erubis (2.7.0)
       Using journey (1.0.3)
       Using rack (1.4.1)
       Using rack-cache (1.2)
       Using rack-test (0.6.1)
       Using hike (1.2.1)
       Using tilt (1.3.3)
       Using sprockets (2.1.3)
       Using actionpack (3.2.3)
       Using mime-types (1.18)
       Using polyglot (0.3.3)
       Using treetop (1.4.10)
       Using mail (2.4.4)
       Using actionmailer (3.2.3)
       Using arel (3.0.2)
       Using tzinfo (0.3.33)
       Using activerecord (3.2.3)
       Using activeresource (3.2.3)
       Using bcrypt-ruby (3.0.1)
       Using cancan (1.6.7)
       Using cocoon (1.0.20)
       Using coffee-script-source (1.3.1)
       Using execjs (1.3.2)
       Using coffee-script (2.2.0)
       Using rack-ssl (1.3.2)
       Using json (1.7.1)
       Using rdoc (3.12)
       Using thor (0.14.6)
       Using railties (3.2.3)
       Using coffee-rails (3.2.2)
       Using commonjs (0.2.6)
       Using daemons (1.1.8)
       Using orm_adapter (0.0.7)
       Using warden (1.1.1)
       Using devise (2.0.4)
       Using eventmachine (0.12.10)
       Using google-analytics-rails (0.0.2)
       Using haml (3.1.4)
       Using jquery-rails (2.0.2)
       Using jquery-rails-cdn (0.1.0)
       Using json_pure (1.6.6)
       Using less (2.2.1)
       Using less-rails (2.2.3)
       Using libv8 (3.3.10.4)
       Using on_the_spot (1.0.0)
       Using pg (0.13.2)
       Using bundler (1.2.0.rc)
       Using rails (3.2.3)
       Using routing-filter (0.3.0)
       Using sass (3.1.17)
       Using sass-rails (3.2.5)
       Using simple_form (2.0.1)
       Using therubyracer (0.10.1)
       Using thin (1.3.1)
       Using twitter-bootstrap-rails (2.1.0) from git://github.com/seyhunak/twitter-bootstrap-rails.git (at master)
       Using uglifier (1.2.4)
       Using validate_url (0.2.0)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for Ruby/Rack -> console, rake, web
-----> Compiled slug size is 18.7MB
-----> Launching... done, v20
       http://dcaclab3.herokuapp.com deployed to Heroku

To git@heroku.com:dcaclab3.git
   f434d33..55a0159  master -> master
sam@ubuntu:~/RubymineProjects/dcaclab/config$ heroku run bash -a dcaclab3
Running `bash` attached to terminal... up, run.1
~ $ dir
app  config.ru  doc  Gemfile.lock  public    README.rdoc  test
bin  db     Gemfile  lib           Rakefile  script       vendor

编辑 5

为了确保推送中的问题以及我的本地提交工作正常:

sam@ubuntu:~/RubymineProjects/dcaclab$ git ls-files config/
config/application.rb
config/boot.rb
config/database.yml
config/environment.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/initializers/backtrace_silencers.rb
config/initializers/devise.rb
config/initializers/inflections.rb
config/initializers/mail.rb
config/initializers/mime_types.rb
config/initializers/secret_token.rb
config/initializers/session_store.rb
config/initializers/simple_form.rb
config/initializers/task_scheduler.rb
config/initializers/wrap_parameters.rb
config/locales/ar.yml
config/locales/devise.en.yml
config/locales/en.yml
config/locales/simple_form.en.yml
config/newrelic.yml
config/routes.rb
config/test_file

编辑 6

确保没有其他 .gitignore 潜伏

sam@ubuntu:~/RubymineProjects/dcaclab$ ~/.gitignore
bash: /home/sam/.gitignore: No such file or directory

sam@ubuntu:~/RubymineProjects/dcaclab$ find ~/RubymineProjects/dcaclab -name ".gitignore"
/home/sam/RubymineProjects/dcaclab/.gitignore
  1. 从 $GIT_DIR/info/exclude 读取的模式。

    sam@ubuntu:~/RubymineProjects/dcaclab$ cat ~/RubymineProjects/dcaclab/.git/exclude cat: /home/sam/RubymineProjects/dcaclab/.git/exclude: 没有这样的文件或目录

【问题讨论】:

  • 您的意思是.git/config 还是一个名为“config”的非空目录?
  • 它是一个名为 'config' 的非空目录
  • cat .gitignorels config/ 告诉你什么? (根据@umlaeute 的回复)
  • cat .gitignore 不会显示任何与 config 文件夹相关的内容,至于 ls config/ 请参见上面的 EDIT
  • 关于EDIT5:你正在做cat ~/RubymineProjects/dcaclab/.git/exclude,而你真正应该做的是cat ~/RubymineProjects/dcaclab/.git/info/exclude

标签: git deployment heroku


【解决方案1】:

git 查找被忽略文件的位置有限。让我们检查所有这些(转述自man gitignore):

1.   Patterns read from the command line for those commands that support them.

2.   Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to
     the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match
     relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files
     generated as part of the project build.

3.   Patterns read from $GIT_DIR/info/exclude.

4.   Patterns read from the file specified by the configuration variable core.excludesfile.

不是1。您正在使用不支持 CLI 排除的瓷器命令。根据您当前的编辑,它仍然可能是 2~/.gitignore 中有什么,并发出 find ~/RubymineProjects/dcaclab -name ".gitignore" 以确认您没有其他人潜伏。要测试3,请发出cat ~/RubymineProjects/dcaclab/.git/exclude。要测试4,请发出git config core.excludefilegit config --global core.excludefile 并在输出中进行编辑。

【讨论】:

  • 我不确定第4点,我发出了 git config core.excludefile 和 git config --global core.excludefile ,但是那里没有输出,你能解释一下吗?
  • 如果您没有看到任何输出,这意味着没有设置这些变量,所以我看到的唯一一个不在您的编辑中的是数字 3。您尝试过那个吗?我可能错过了。
【解决方案2】:

1 个空目录

git 不会签入一个空目录,所以如果你的“config”目录是空的,它不会被包含在你的提交中。通过添加一个虚拟文件来“修复”它

touch config/nada
git add config/nada
git commit config/nada -m "dummy file to force inclusion of config/"
git push heroku master

2 gitignore

您的 config/ 目录中的文件可能位于某个全局或系统范围的 .gitignore 文件中

EDIT1:

您可以通过多种方式指定 git 排除的文件。您可能需要检查所有这些以查看您是否忽略了配置目录:

  • 命令行参数(可能不是你的问题)

  • git 仓库目录中的.gitignore 文件

  • $GIT_DIR/info/exclude

  • 由 core.excludes 属性指定的文件(系统范围或全局)

    git config core.excludes

    git config --global core.excludes

    git config --system core.excludes

检查所有可能性,最终将它们发布在这里(或某个粘贴箱)

在任何情况下,您都应该能够通过显式添加文件来覆盖排除:

git add config/foo.conf
git commit config/foo.conf -m "manually added foo.conf"
git push heroku master

EDIT2:

3 推...

我不认为“推送”是问题,而是将文件添加到存储库。 确认,配置文件确实在 git 控制之下。 例如添加/提交文件后:

git ls-files config/

并确保文件在那里。

EDIT3:

另外,很可能是您正确推送到heroku,但他们没有按预期将您的存储库同步到部署,因此远程控制台不显示配置(或者因为它被排除在同步之外,因为它最终出现在其他地方,或者因为它在显示时被过滤掉了;或者因为你实际上看错了地方)

这样做:

$ git add config/foo.conf
$ git commit config/foo.conf -m "manually added foo.conf"
$ git push heroku master

$ cd /tmp
$ git clone <remote-url-for-heroku> testclone
$ ls testclone/config/

如果这有效,那么在 heroku 网站上的结帐有问题。 也许你需要做这样的事情:

$ heroku run bash -a dcaclab3
[...]
$$ git pull
$$ ls config/

【讨论】:

  • 不,它不是空目录,至于添加配置目录请参见上面的编辑
  • 尝试用“git add config/file”显式添加你的文件,而不是用“git add”隐式添加。
  • 在答案中查看我的 EDIT1,了解排除文件的各种方法(ala .gitignore)
  • 实际上,是什么让您认为失败的是“推送”而不是“提交”?所有答案都试图解决“提交”问题(我同意),但你应该确保......见 EDIT2
  • 我已经检查了你的 EDIT 2,请看我的 EDIT 5,config 文件夹在 git-control 下
【解决方案3】:

当我联系 heroku 时,我们发现删除文件 .gitignore 旁边的文件 .slugignore 解决了问题!

所以,这是heroku方面的一个错误,遗憾的是这就是原因,感谢所有试图帮助解决这个问题的人。

【讨论】:

    猜你喜欢
    • 2012-04-26
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-15
    • 1970-01-01
    相关资源
    最近更新 更多