|
|
(One intermediate revision by the same user not shown) |
Line 14: |
Line 14: |
| git init | | git init |
| </source> | | </source> |
|
| |
| </blockquote><!-- creating a repo --> | | </blockquote><!-- creating a repo --> |
|
| |
| = Git Transfer Protocols =
| |
| <blockquote>
| |
| Git can communicate using a variety of protocols. Personally, I like using ssh best since it is secure,
| |
| universal, and I'm already using it.
| |
|
| |
| == ssh ==
| |
| <blockquote>
| |
| First, create a git repo on a server that is accessible using ssh. See [[openssh]] .
| |
| Next, add a git remote to your project referring to it using the ssh protocol.
| |
|
| |
| <source lang="bash">
| |
| git remote add origin ssh://git@gitbox:8610/home/git/my_project
| |
| git --set-upstream origin --all
| |
| git push
| |
| </source>
| |
|
| |
| Technically, this is all you need. It would be prudent to create a <code>git</code> user
| |
| with minimal privileges, and configured to use <code>git-shell</code> (which allows pull/push only).
| |
| </blockquote><!-- ssh -->
| |
|
| |
| == git:// (read-only) ==
| |
| <blockquote>
| |
| The only reason I really care about this is to import existing
| |
| projects into github.
| |
|
| |
| {{ WARNING |
| |
| Make sure to add the (empty) file git-daemon-export-ok to every repository
| |
| that you want to allow git-daemon to access. Otherwise access denied.
| |
| }}
| |
|
| |
| <source lang="bash">
| |
| sudo systemctl enable git-daemon
| |
| sudo systemctl start git-daemon
| |
|
| |
| mkdir /srv/git
| |
| </source>
| |
|
| |
| <source lang="bash">
| |
| echo "git_daemon_enable=\"YES\"" >> /etc/rc.conf
| |
| service git_daemon start
| |
|
| |
| mkdir /usr/local/git
| |
| chown git:git /usr/local/git #NOTE: even though the daemon runs as git_daemon, the dir should be owned by git
| |
|
| |
| </source>
| |
|
| |
| Copy your project to the remote location.
| |
| <source lang="bash">
| |
| cp -Ra /home/git/<project> /usr/local/git
| |
| touch /usr/local/git/<project>/git-daemon-export-ok # git daemon only exposes projects with
| |
| # this file
| |
|
| |
| </source>
| |
|
| |
| <source lang="bash">
| |
| # daemon is started with following options: /usr/lib/git-core/git-daemon --inetd --export-all --base-path=/srv/git
| |
| #
| |
| # (repositories in /srv/git/ (linux) /usr/local/git (freebsd) will be able to be cloned)
| |
|
| |
| git clone git://gitbox:9418/usr/local/git/repository.git
| |
|
| |
| </source>
| |
|
| |
| </blockquote><!-- git:// -->
| |
| </blockquote><!-- protocols -->
| |
|
| |
|
| |
|
| = Special Cases = | | = Special Cases = |
| <blockquote> | | <blockquote> |
|
| |
| == Verify == | | == Verify == |
| <blockquote> | | <blockquote> |