如何在 Ubuntu 中设置私有 git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7069176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:49:56  来源:igfitidea点击:

How do I setup a private git repository in Ubuntu?

gitubuntu

提问by KRB

I use a git repository at work on GitHub. I know the basic commands for navigating and editing a repository but I don't know how to set one up from scratch.

我在 GitHub 上工作时使用 git 存储库。我知道导航和编辑存储库的基本命令,但我不知道如何从头开始设置。

I would like to setup my own server for the git repo so my buddies can come help me with the game I'm developing for Android. But I don't know how!

我想为 git repo 设置我自己的服务器,这样我的朋友就可以来帮助我开发我为 Android 开发的游戏。但我不知道怎么做!

Would Gitosis be the best choice for this?

Gitosis 会是最好的选择吗?

回答by avh

IMO the simplest way is to use ssh. If you have a machine that you and your buddies can all ssh to, then you just make a bare clone of your repository, put it up on the ssh server, and clone it from there. I do this using my dreamhost account as the server.

IMO 最简单的方法是使用 ssh。如果您有一台您和您的伙伴都可以通过 ssh 连接的机器,那么您只需对您的存储库进行裸克隆,将其放在 ssh 服务器上,然后从那里克隆它。我使用我的 Dreamhost 帐户作为服务器来执行此操作。

cd my-repo
cd ..
# Make a bare copy of the repo
git clone --bare my-repo my-repo.git
# Upload the bare copy to the server
# -- in this case, I've already created a /repos folder to hold the bare repos
rsync my-repo.git/ mysshserver:/repos/my-repo.git/
# Add the new server repo as a remote to your local repository
cd my-repo
git remote add origin mysshserver:/repos/my-repo.git

Then for your buddies:

那么对于小伙伴们:

git clone mysshserver:/repos/my-repo.git/

The only trick is making sure all the user accounts you are using have write permissions to the repo folder (/repos/my-repo.git/* on the server).

唯一的技巧是确保您使用的所有用户帐户都具有对 repo 文件夹(服务器上的/repos/my-repo.git/*)的写入权限。

回答by takeshin

First, You need to create the repo (easy as git init)
Second, You need to give your buddies access to the repo.

首先,您需要创建存储库(很简单git init
其次,您需要让您的好友访问存储库。

You may use few options which git handles:

您可以使用 git 处理的几个选项:

  • via file://(direct access on LAN)
  • via ftp
  • via git protocol (ssh access)
  • 通过file://(直接在局域网上访问)
  • 通过ftp
  • 通过 git 协议(ssh 访问)

Third, manage the access, permissions etc.

第三,管理访问、权限等。

For this, the best option is gitolite, better than gitosis. There is a good installation guide in the repo. The most tricky part is setting up passwordless access to the server (but this this is not actually git related). Using Ubuntu and Github you probably know what for are public ssh keys.

为此,最好的选择是gitolite,比gitosis. 回购中有一个很好的安装指南。最棘手的部分是设置对服务器的无密码访问(但这实际上与 git 无关)。使用 Ubuntu 和 Github,您可能知道公共 ssh 密钥是什么。

Gitolite is the best option so far, but a bit complex. However, if you don't want to use gitolite, you may still only to init the repo, and make the machine accessible, which is the simplest solution.

Gitolite 是目前最好的选择,但有点复杂。但是,如果您不想使用gitolite,您可能仍然只初始化repo,并使机器可访问,这是最简单的解决方案。

See also Setting Up the Serverfrom the free Pro Gitbook. There are chapters about gitoliteand gitosisas well.

另请参阅免费的Pro Git书籍中的设置服务器。还有关于gitolitegitosis 的章节。