tags:

views:

504

answers:

3

I'd like to include a file in my .gitconfig that has my github settings - is this possible?

Can I do something like this:

[core]
    include = /path/to/file
+4  A: 

I do not think so.

I would rather put that setting in the ~/.gitconfig file

User-specific configuration file. Also called "global" configuration file.

That way, it completes the .gitconfig project-specific file, without being published when pushed to GitHub. See also this SO answer for more on the global config file.
Git has 3 config files.


bjeanes adds in the comments:

it looks like everyone missed the point of this question.
David obviously wants to push up a repo of all his dot files (bashrc, gemrc, etc.) INCLUDING his .gitconfig so he can have all his settings on all his machines.
A way to push parts of a .gitconfig file by including and ignoring private entries is what he (and I, for that matter) is after.

A possible way would be to use a smudge/clean filter driver to decrypt/encrypt one file with private sensitive informations (see this thread), in order to complete a local file like ~/.gitconfig with the decrypted parts that are relevant to that file.

That way you can have a Git repo with all your dot files, plus one file with encrypted information meant to be decrypted and added to said dot files.

alt text

In .gitattributes (or.git/info/a..) use:

myPrivateInfosFile filter=gpg diff=gpg

In your repo .config file:

[filter "gpg"]
smudge = gpg -d -q --batch --no-tty
clean = gpg -ea -q --batch --no-tty -r C920A124
[diff "gpg"]
textconv = decrypt

(a GPG-based solution means, off course, you have communicated your private/public keys by another mean onto the destination computer where you want to restore all your dot files by cloning this special repo)

Actually, in your case, the smudge script needs to be completed as it must, after decrypted that file, go on and add relevant parts to your global ~/.gitconfig file (unless you overwrite the global config file with another location) or other dot files for that matter.

https://kerneltrap.org/mailarchive/git/2008/3/13/1153274/thread (gpg inconveniences are discussed further in this thread) (this is different than having a full encrytped Git repo, as discussed here)

VonC
I want to publish my basic .gitconfig file in a git repository, but I don't want to include the github details in it, hence why I would like to include them from an external file somehow.
David Reynolds
+1  A: 

As of May 2010 this is not possible. Sadly.

Reference: May 2010 git mailing list thread proposing to add such feature: http://kerneltrap.org/mailarchive/git/2010/5/8/30030/thread

NicDumZ
A: 

Use an additional private branch, whose diffs with master are the lines that it included personal data. And you should always checkout and develop in private in localhost, only merge the commits you want to publish into master (my way is to use git cherry-pick), and only push master to github.

A detailed blog post targetting your problem (employing another method mainly using git rebase): http://loupgaroublond.blogspot.com/2008/09/keeping-private-config-files-private-in.html

In the comments of the post above, someone said: Or you could use stgit to maintain a stack of "local-only" patches... seems like a much simpler method to me! I think it's a good way to go too, the blog post about this way: https://geekrelief.wordpress.com/2009/06/26/stgit-stacked-git-tutorial-for-managing-patches/

Tianyi Cui