Create a new GIT repository

Create simple local repo

that can be used locally and remotely

    cd somefolder/
    git init

Create real (bare) repo

that will be used remotely only

prepare the git user with remote access,

    groupadd sshusers
    useradd -m -G sshusers -s /usr/bin/git-shell git
    usermod -p '*' git

    vi /etc/ssh/sshd_config

    AllowGroups sshusers
    PermitRootLogin without-password
    PasswordAuthentication no

    systemctl restart sshd

as git user on the GIT server,

    mkdir REPO.git/
    cd REPO.git/
    git init --bare

and in case you want the path to be short, this is dirty but works,

    git init --bare ~/REPO.git/
    mv ~/REPO.git/ /
    chown -R git.nogroup /REPO.git/

now assuming SSH is available on the default port,

    git clone git@gitsrv:/REPO.git

Using Github

Quoting Github’s repo startup doc,

echo "# doc" >>
git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master

…or push an existing repository from the command line

git remote add origin
git push -u origin master

Once your repo is up and running you can then fetch it using git-clone e.g.,

#git clone
git clone ssh://
#git clone

Push to a remote repo after you started already

you can also create your own,

    cd project/
    git init
    git add *
    #git add --all
    git commit -m MESSAGE

and sync with the remote repo afterwards,

    git remote add origin ssh://git@gitsrv/home/git/project.git
    #git config --global push.default simple
    git push
    #git push --set-upstream origin master


Copyright © 2024 Pierre-Philipp Braun