pistacchio
pistacchio

Reputation: 58903

Git export of a single branch

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?

Upvotes: 2

Views: 5478

Answers (2)

Marcin Gil
Marcin Gil

Reputation: 69535

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

Upvotes: 2

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143229

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.

Upvotes: 0

Related Questions