setup-git-hosting - www.codemadness.org - www.codemadness.org saait content files
(HTM) git clone git://git.codemadness.org/www.codemadness.org
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
setup-git-hosting (10567B)
---
1 1<- Back / codemadness.org 70
2 i codemadness.org 70
3 i codemadness.org 70
4 i# Setup your own git hosting service codemadness.org 70
5 i codemadness.org 70
6 iLast modification on 2022-08-07 codemadness.org 70
7 i codemadness.org 70
8 i**This article assumes you use OpenBSD for the service files and OS-specific codemadness.org 70
9 iexamples.** codemadness.org 70
10 i codemadness.org 70
11 i codemadness.org 70
12 i## Why codemadness.org 70
13 i codemadness.org 70
14 iA good reason to host your own git repositories is because of having and codemadness.org 70
15 ikeeping control over your own computing infrastructure. codemadness.org 70
16 i codemadness.org 70
17 iSome bad examples: codemadness.org 70
18 i codemadness.org 70
19 h* The SourceForge ads/malware/hijack controversies. Injecting malware into projects. URL:https://en.wikipedia.org/wiki/SourceForge#Controversies codemadness.org 70
20 h* As of 2019-10-23 Gitlab added telemetry to their software. URL:https://gitlab.com/gitlab-org/gitaly/issues/2113 codemadness.org 70
21 h* On 2019-10-24 Gitlab reverted it again because many people complained. URL:https://about.gitlab.com/blog/2019/10/10/update-free-software-and-telemetry/ codemadness.org 70
22 h* On 2020-11-16 Github reinstated youtube-dl, to reverse a Digital Millennium Copyright Act (DMCA) takedown. URL:https://github.blog/2020-11-16-standing-up-for-developers-youtube-dl-is-back/ codemadness.org 70
23 h* On 2021-03-11 Github (owned by Microsoft) removes exploit code for Microsoft Exchange vulnerabilities. URL:https://arstechnica.com/gadgets/2021/03/critics-fume-after-github-removes-exploit-code-for-exchange-vulnerabilities/ codemadness.org 70
24 h* On 2022-04-16 Russian software developers are reporting that their GitHub accounts are being suspended without warning if they work for or previously worked for companies under US sanctions. URL:https://www.bleepingcomputer.com/news/security/github-suspends-accounts-of-russian-devs-at-sanctioned-companies/ codemadness.org 70
25 h* On 2022-08-04 GitLab plans to delete dormant projects in free accounts. URL:https://www.theregister.com/2022/08/04/gitlab_data_retention_policy/ codemadness.org 70
26 h* On 2022-08-05 GitLab U-turns on deleting dormant projects after backlash. URL:https://www.theregister.com/2022/08/05/gitlab_reverses_deletion_policy/ codemadness.org 70
27 i codemadness.org 70
28 iThe same thing can happen with Github, Atlassian Bitbucket or other similar codemadness.org 70
29 iservices. After all: they are just a company with commercial interests. These codemadness.org 70
30 ionline services also have different pricing plans and various (arbitrary) codemadness.org 70
31 irestrictions. When you host it yourself the restrictions are the resource codemadness.org 70
32 ilimits of the system and your connection, therefore it is a much more flexible codemadness.org 70
33 isolution. codemadness.org 70
34 i codemadness.org 70
35 hAlways make sure you own the software (which is »Free« or open-source) and you URL:https://www.gnu.org/philosophy/free-sw.html codemadness.org 70
36 ican host it yourself, so you will be in control of it. codemadness.org 70
37 i codemadness.org 70
38 i codemadness.org 70
39 i## Creating repositories codemadness.org 70
40 i codemadness.org 70
41 iFor the hosting it is recommended to use a so-called "bare" repository. A bare codemadness.org 70
42 irepository means no files are checked out in the folder itself. To create a codemadness.org 70
43 ibare repository use git init with the --bare argument: codemadness.org 70
44 i codemadness.org 70
45 i $ git init --bare codemadness.org 70
46 i codemadness.org 70
47 iI recommend to create a separate user and group for the source-code codemadness.org 70
48 irepositories. In the examples we will assume the user is called "src". codemadness.org 70
49 i codemadness.org 70
50 iLogin as the src user and create the files. To create a directory for the codemadness.org 70
51 irepos, in this example /home/src/src: codemadness.org 70
52 i codemadness.org 70
53 i $ mkdir -p /home/src/src codemadness.org 70
54 i $ cd /home/src/src codemadness.org 70
55 i $ git init --bare someproject codemadness.org 70
56 i $ $EDITOR someproject/description codemadness.org 70
57 i codemadness.org 70
58 iMake sure the git-daemon process has access permissions to these repositories. codemadness.org 70
59 i codemadness.org 70
60 i codemadness.org 70
61 i## Install git-daemon (optional) codemadness.org 70
62 i codemadness.org 70
63 iUsing git-daemon you can clone the repositories publicly using the efficient codemadness.org 70
64 igit:// protocol. An alternative without having to use git-daemon is by using codemadness.org 70
65 i(anonymous) SSH, HTTPS or any public shared filesystem. codemadness.org 70
66 i codemadness.org 70
67 iWhen you use a private-only repository I recommend to just use SSH without codemadness.org 70
68 igit-daemon because it is secure. codemadness.org 70
69 i codemadness.org 70
70 iInstall the git package. The package should contain "git daemon": codemadness.org 70
71 i codemadness.org 70
72 i # pkg_add git codemadness.org 70
73 i codemadness.org 70
74 iEnable the daemon: codemadness.org 70
75 i codemadness.org 70
76 i # rcctl enable gitdaemon codemadness.org 70
77 i codemadness.org 70
78 iSet the gitdaemon service flags to use the src directory and use all the codemadness.org 70
79 iavailable repositories in this directory. The command-line flags "--export-all" codemadness.org 70
80 iexports all repositories in the base path. Alternatively you can use the codemadness.org 70
81 i"git-daemon-export-ok" file (see the git-daemon man page). codemadness.org 70
82 i codemadness.org 70
83 i # rcctl set gitdaemon flags --export-all --base-path="/home/src/src" codemadness.org 70
84 i codemadness.org 70
85 iTo configure the service to run as the user _gitdaemon: codemadness.org 70
86 i codemadness.org 70
87 i # rcctl set gitdaemon user _gitdaemon codemadness.org 70
88 i codemadness.org 70
89 iTo run the daemon directly as the user _gitdaemon (without dropping privileges codemadness.org 70
90 ifrom root to the user) set the following flags in /etc/rc.d/gitdaemon: codemadness.org 70
91 i codemadness.org 70
92 i daemon_flags="--user=_gitdaemon" codemadness.org 70
93 i codemadness.org 70
94 iWhich will also avoid this warning while cloning: codemadness.org 70
95 i codemadness.org 70
96 i "can't access /root/.git/config" codemadness.org 70
97 i codemadness.org 70
98 iNow start the daemon: codemadness.org 70
99 i codemadness.org 70
100 i # rcctl start gitdaemon codemadness.org 70
101 i codemadness.org 70
102 i codemadness.org 70
103 i## Cloning and fetching changes codemadness.org 70
104 i codemadness.org 70
105 iTo test and clone the repository do: codemadness.org 70
106 i codemadness.org 70
107 i $ git clone git://yourdomain/someproject codemadness.org 70
108 i codemadness.org 70
109 iif you skipped the optional git-daemon installation then just clone via SSH: codemadness.org 70
110 i codemadness.org 70
111 i $ git clone ssh://youraccount@yourdomain:/home/src/src/someproject codemadness.org 70
112 i codemadness.org 70
113 iWhen cloning via SSH make sure to setup private/public key authentication for codemadness.org 70
114 isecurity and convenience. codemadness.org 70
115 i codemadness.org 70
116 iYou should also make sure the firewall allows connections to the services like codemadness.org 70
117 ithe git daemon, HTTPd or SSH, for example using OpenBSD pf something like this codemadness.org 70
118 hcan be set in »/etc/pf.conf«: URL:https://man.openbsd.org/pf.conf codemadness.org 70
119 i codemadness.org 70
120 i tcp_services="{ ssh, gopher, http, https, git }" codemadness.org 70
121 i pass in on egress proto tcp from any to (egress) port $tcp_services codemadness.org 70
122 i codemadness.org 70
123 i codemadness.org 70
124 i## Pushing changes codemadness.org 70
125 i codemadness.org 70
126 iAdd the repository as a remote: codemadness.org 70
127 i codemadness.org 70
128 i $ git remote add myremote ssh://youraccount@yourdomain:/home/src/src/someproject codemadness.org 70
129 i codemadness.org 70
130 iThen push the changes: codemadness.org 70
131 i codemadness.org 70
132 i $ git push myremote master:master codemadness.org 70
133 i codemadness.org 70
134 i codemadness.org 70
135 i## Git history web browsing (optional) codemadness.org 70
136 i codemadness.org 70
137 iSometimes it's nice to browse the git history log of the repository in a web codemadness.org 70
138 ibrowser or some other program without having to look at the local repository. codemadness.org 70
139 i codemadness.org 70
140 1* »Stagit« is a static HTML page generator for git. /phlog/stagit codemadness.org 70
141 1* »Stagit-gopher« is a static page generator for /phlog/stagit-gopher codemadness.org 70
142 h »gopher« and URL:http://gopherproject.org/ codemadness.org 70
143 1 geomyidae. /scm/geomyidae bitreich.org 70
144 i* cgit is a CGI-based program which shows HTML views of your repository, see codemadness.org 70
145 1 also the page: »OpenBSD httpd, slowcgi and cgit«. /phlog/openbsd-httpd-and-cgit codemadness.org 70
146 i codemadness.org 70
147 iIt's also possible with these tools to generate an Atom feed and then use a codemadness.org 70
148 iRSS/Atom reader to track the git history: codemadness.org 70
149 i codemadness.org 70
150 h* An example url from cgit: »Linux kernel tree«. URL:https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/atom/?h=master codemadness.org 70
151 0* An example url from stagit for the »commit log«. /git/stagit/atom.xml codemadness.org 70
152 0* An example url from stagit for the »releases«. /git/stagit/tags.xml codemadness.org 70
153 i codemadness.org 70
154 1My »sfeed« program can be used as a RSS/Atom reader. /phlog/sfeed codemadness.org 70
155 i codemadness.org 70
156 i codemadness.org 70
157 i## Setting up git hooks (optional) codemadness.org 70
158 i codemadness.org 70
159 iUsing git hooks you can setup automated triggers, for example when pushing to a codemadness.org 70
160 irepository. Some useful examples can be: codemadness.org 70
161 i codemadness.org 70
162 1* For stagit: update the repo files (example post-receive hook). /git/stagit/file/example_post-receive.sh.gph codemadness.org 70
163 i* Send an e-mail with the commit subject and message. codemadness.org 70
164 h* Log/notify commits and changes to an IRC channel using a fifo: »ii«. URL:https://tools.suckless.org/ii/ codemadness.org 70
165 i* Create a release tarball and checksum file on a tag push/change. codemadness.org 70
166 i* Checkout files for website content. codemadness.org 70
167 .