tags:

views:

181

answers:

2

Hi,

I worked locally on a git repository. It has various branches like a dev branch, some branch for experimental changes and so on. And of course a master branch.

I want to setup a public (well, indeed it's a lan thing, better say "shared") repository to only contain the master branch.

How to export that branch so that i can copy it to the destination folder? Thanks

A: 

I'd consider setting up separate public repository with "alternates" pointing to the one you're working on and push your branch to it. Or maybe symlink the master branch to the one in your local repository. I haven't tried that, but it should work.

Michael Krelin - hacker
+1  A: 

As the git-push manual says:

git push origin HEAD:master

Push the current branch to the remote ref matching master in the origin repository. This form is convenient to push the current branch without thinking about its local name.

or

git push origin HEAD

A handy way to push the current branch to the same name on the remote.

Using these commands you do:

  1. Create git init --bare repository at some "shared location"
  2. git remote add origin this location to your current working repository
  3. git push --force origin HEAD from your master branch
  4. Other devs now can clone that repository with only master branch
Marcin Gil
Oh, is OP talking about remote public repository?
Michael Krelin - hacker
He exactly says he want's to create new repo. Doesn't matter if that's really remote or just another directory. Added some info to clarify. Thanks.
Marcin Gil
Well, it does. If it's locally, I wouldn't like the solution you propose.
Michael Krelin - hacker
Care to explain why? It works for me. As it is a "lan thing" then it can be that this directory will be shared over CFS/Samba or served via ssh.
Marcin Gil
Sure it works. The drawbacks are (a) you have to push each time you commit (with alternates and symlink trick that should do automatically) and (b) it takes twice as much space, although in case of local machine could be fixed in your solution (it will turn it into a repetition of the first part of my proposal;-)). And yes, the "lan thing" of course leaves quite some room for imagination.
Michael Krelin - hacker
Well.. In my work I only push to shared repo once a feature/bugfix/etc is ready and not every single commit that can be partial solution. As for the space requirement, well.. disks are cheap now and you gain repo separation: your own workplace and what you share with others. Moreover symlinking to your own workplace as shared place will share what you have actually checked out won't it?
Marcin Gil