Git export of a single branch

匿名 (未验证) 提交于 2019-12-03 01:04:01

问题:

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

回答1:

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


回答2:

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.



转载请标明出处:Git export of a single branch
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!