<?php $host = parse_url(CLONE_BASE, PHP_URL_HOST) ?: 'this-server'; ?>
<div class="box readme">
  <div class="box-header">
    <svg class="icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM8 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4c.73 0 1.334.192 1.752.545.416.353.65.822.667 1.328.033.988-.65 1.606-1.166 2.02l-.147.117c-.363.288-.573.485-.573.86v.007a.75.75 0 0 1-1.5-.037c.03-.673.457-1.109.877-1.454l.087-.07c.529-.421.867-.723.85-1.132-.007-.174-.09-.375-.323-.564-.234-.19-.575-.32-1.024-.32-.44 0-.77.12-.996.26a1.28 1.28 0 0 0-.481.523ZM8 12a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"></path></svg>
    Help
  </div>
  <div class="body">

<p>Two kinds of commands below: plain <code>git</code> commands (work with any git server, nothing
special about this one) and <code>ssh git@<?= h($host) ?> &lt;word&gt;</code> ones — those run a small
set of admin commands this server defines for itself (create a repo, set its description, delete
it). They look like git subcommands but aren't; git itself has no <code>create</code>,
<code>describe</code>, or <code>delete</code> built in that does this — there's no such thing as
"deleting a repo" in git, a repo is just a directory. (git *does* have its own unrelated
<code>git describe</code> — it prints the nearest tag reachable from a commit. Different thing
entirely from the SSH one below.)</p>

<h2>First time on this machine? Set your identity</h2>
<p>Every commit records who made it. Git won't guess — set this once per machine (or drop
<code>--global</code> to set it just for the repo you're in):</p>
<pre><code>git config --global user.name "Your Name"
git config --global user.email "you@example.com"</code></pre>
<p>Use the same name and email everywhere you push from, so your commits look like one person
across repos when others are collaborating with you.</p>

<h2>Cloning a repo</h2>
<p>No account needed to read. Pick either:</p>
<pre><code># read-only, no credentials
git clone <?= h(CLONE_BASE) ?>&lt;repo&gt;.git

# needs an SSH key registered on the server (see below) -- required for push
git clone git@<?= h($host) ?>:repos/&lt;repo&gt;.git</code></pre>
<p>The exact command for a given repo is also on that repo's own page — click the clone box to copy it.</p>

<h2>Everyday git</h2>
<pre><code>git status              # what's changed
git add &lt;file&gt;          # stage a file (git add -A for everything)
git commit -m "message" # commit what's staged
git push                # send your commits to the server
git pull                # fetch + merge the server's commits into yours
git log                 # history
git diff                # uncommitted changes, in detail
git branch              # list branches
git switch -c &lt;name&gt;    # create and switch to a new branch</code></pre>

<h2>Putting a new project up here</h2>
<p>Either direction works — start with a repo already on the server, or start with a folder you
already have. Both need an SSH key registered here first (see below).</p>
<p><strong>Already have a local folder?</strong> Turn it into a repo, then push it up:</p>
<pre><code>cd my-project
git init
git add -A
git commit -m "Initial commit"
ssh git@<?= h($host) ?> create my-project
git remote add origin git@<?= h($host) ?>:repos/my-project.git
git push -u origin main   # or "master" -- whatever git init used</code></pre>
<p><strong>Starting from nothing?</strong> Create the repo first, clone the (empty) result, then add files:</p>
<pre><code>ssh git@<?= h($host) ?> create my-project
git clone git@<?= h($host) ?>:repos/my-project.git
cd my-project
# ...add files, then...
git add -A
git commit -m "Initial commit"
git push</code></pre>

<h2>Setting a repo's description</h2>
<p>Shows up in the repo list and in the box at the top of the repo's pages here. This is the
server's own <code>describe</code> SSH command (see the note up top) — not <code>git describe</code>.</p>
<pre><code>ssh git@<?= h($host) ?> describe &lt;reponame&gt; "A short description"</code></pre>

<h2>Deleting a repo</h2>
<p>Permanent — this removes the bare repo and its whole history, no trash/undo. The name has to be
typed twice as a confirmation; if the two don't match, nothing is deleted.</p>
<pre><code>ssh git@<?= h($host) ?> delete &lt;reponame&gt; &lt;reponame&gt;</code></pre>

<h2>Getting push access</h2>
<p>Push (and repo creation) needs your SSH public key added to the server. Send it to the admin,
or if you're the admin: <code>sudo bash server/add-key.sh</code> from the foxygit checkout.</p>

  </div>
</div>
