3

I've just started using git-ftp, which allows me to push my commit to an FTP server.

The FTP credentials are stored in .git/config in this way:

[git-ftp]
    user = myusername
    url = ftp.myserver.com/httpdocs/
    password = mypass

What I would like, is that anyone who clones the project from my git repository, automatically gets the configuration above as well.

But how can I 'push' this git configuration to my repo?

Read more about git-ftp: https://github.com/resmo/git-ftp

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Harold Smith
  • 882
  • 3
  • 12
  • 21

2 Answers2

5

This is not possible as explained in this SO answer. Git config file is always local to a repository, and can't be pushed or fetched. Best solution is to put a file containing the git-ftp parameters (excepted the password), and display instructions in a README.

Community
  • 1
  • 1
CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • Now I think of it, even though I initially liked your idea about the README, that would be a dangerous approach when the files are published to the web server. The README would then become publicly viewable. And though git-ftp does support excludes, that itself would need to be configured each time as well. Another solution would be to configure it globally using scopes (explained in the git-ftp documentation on github). – Harold Smith Apr 11 '12 at 15:16
  • That's why config files are never pushed to remote repositories :-) Anyway NEVER put any password in a text file without serious thinking of the risk that it can be read – CharlesB Apr 11 '12 at 15:19
1

I think, generally, if we are talking about the plain Git, you could dedicate a special Git branch for storing your configs, say, git-config. Probably it will be disconnected from all your other history in this repo.

And write special programs to save your current config as a commit in that branch, and to retrieve the config from there.

Then, if you push that branch somewhere, and tell them to use your save-and-retrieve programs, they'll have it. If you clone your repo somewhere, too, your config will be available in the new repo in the special branch. You only need to use the script to retrieve it from there.

You can even merge different configs with Git then.

Somee programs that extend Git like git-annex use this approach; their per-repo data is stored in a special branch, and thus can be exchanged and merged by Git.

(Of course, it's a bad idea to publish the password through VCS.)

imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104