Creating 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 nogroup -G sshusers -s /usr/bin/git-shell git
    vi /etc/ssh/sshd_config

    AllowGroups sshusers
    PermitRootLogin without-password
    PasswordAuthentication no
    StrictModes yes
    X11Forwarding no

    systemctl restart ssh

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" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:elge9/doc.git
git push -u origin master

…or push an existing repository from the command line

git remote add origin git@github.com:elge9/doc.git
git push -u origin master

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

#git clone https://github.com/pbraun9/doc.git
git clone ssh://git@github.com/pbraun9/doc.git
#git clone git@github.com:pbraun9/doc.git

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