开发者

How can I set up my own local Git server on my own computer?

开发者 https://www.devze.com 2023-02-20 06:30 出处:网络
I want to use my own server (i.e. 127.0.0.1) w开发者_开发问答hen I use the push command. How can I set up my own server?

I want to use my own server (i.e. 127.0.0.1) w开发者_开发问答hen I use the push command. How can I set up my own server?

I'm using MacOS X.


You don't need a server to push to a local repository. You can just use a local file url as indicated in the git-push manual:

For local repositories, also supported by git natively, the following syntaxes may be used:

  • /path/to/repo.git/
  • file:///path/to/repo.git/


Mat already provided a correct answer for the common case, but if you want to test networked commits locally, the easiest way is to set up an ssh daemon on your machine (if OSX doesn't already installs one by default - not sure).

Once ssh is set up, you can push to any repository on your local machine by setting up a remote:

  git remote add repo-name user@127.0.0.1:/path/to/your/repo

  git push repo-name branch-name

Keep in mind that repositories that are intended for pushing to (remotely or locally) should generally be initialized with git init --bare; or at least not have any branch you intend to push checked out in the working tree.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号