repository specific gitignore files

160 views
Skip to first unread message

naveen

unread,
Aug 27, 2009, 10:54:25 PM8/27/09
to msysGit
There are particular files that i can not distribute widely due to
licensing issues, but would like to be able to use privately...
I would like to be able to push a set of files to the public
repository, and a larger set of files to a private repository...
Is this possible with gitignore / exclude files or do i have to keep
two separate repositories on my laptop as well?

David Aguilar

unread,
Aug 28, 2009, 6:16:08 AM8/28/09
to naveen, msysGit

.git/info/exclude is a per-repository .gitignore file that is
not distributed when you push, clone, etc.

It sounds like you'll need a different setup to accomplish
this, though. It sounds like you need two branches:
let's call them "public" and "private".

Your "private" branch would be a superset of the "public"
branch.

The public branch would be used to edit anything that's meant
for public consumption.

The private branch should never touch the public parts;
it should only ever modify the files that you've deemed
private. To pickup changes to public stuff you'd simply
git merge public.

Whenever you need to change any of the private bits you
simply checkout the private branch and commit stuff there.

Distributing your repo is simple now that you have the
two branches. Simply push the public branch out to the
public repositories and never push the private branch
there.

The "private is a superset of public" is enforced by
the merging strategy -- all the public work happens
in the public branch and the private branch merges
those changes in periodically:

# merge public into private
$ git checkout private
$ git merge public

Never merge the other way (private into public) and
you're set.

--

David


naveen

unread,
Aug 28, 2009, 10:44:57 AM8/28/09
to David Aguilar, msy...@googlegroups.com
> It sounds like you need two branches:
> let's call them "public" and "private"...

>         # merge public into private
>         $ git checkout private
>         $ git merge public
>
> Never merge the other way (private into public) and
> you're set.
Thanks David, I will do that accept keep separate repositories on my
laptop, for a combination of other reasons.

I think remote repository specific .gitignore directives could also be
used to more easily manage subprojects if implemented internally. What
do you think?

I do intend to build git myself one of these days so this is partially
a wish, and partially a request for comment... Or maybe i just need to
understand the subproject handling of git a little better

Junio C Hamano

unread,
Aug 28, 2009, 8:14:58 PM8/28/09
to naveen, msysGit
naveen <navee...@gmail.com> writes:

The recipe David gave you is the most appropriate.

The ignore mechanism is about what to do with untracked files (i.e. "do
you want to get reminded that you might have forgotten to 'git add'
them?"). When you are talking about committed files (and merge, push,
commit are all about commited files), gitignore never gets into the
picture.

naveen

unread,
Aug 31, 2009, 3:58:18 AM8/31/09
to msysGit
>  When you are talking about committed files (and merge, push,
> commit are all about commited files), gitignore never gets into the
> picture.
you are right, i was confused about this.
Reply all
Reply to author
Forward
0 new messages