- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools







How to create git remote repository

How to create git remote repository with ssh

Server side

create user

useradd  gitrepo
echo "gitrepo:gitrepo" |chpasswd

create repogitory

su - gitrepo
mkdir test1.git
cd test1.git
git init --bare --share

Client side

Create project and push to remote repository

mkdir test1
cd test1

git init
echo "git test" > readme
git add .
git commit -m "first commit"
git remote add origin ssh://x.x.x.x/home/gitrepo/testproject.git
git push origin master

git clone, edit and push

git clone ssh://x.x.x.x/home/gitrepo/test1.git
echo "test" >> readme
git add .
git commit -m "change test"
git push origin master
git status

How to create git remote reposigotry with http

Server Side

cd /opt/git
git init --bare --shared project.git
chown -R apache:apache project.git


SetEnv GIT_PROJECT_ROOT /opt/git
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED]

<Files "git-http-backend">
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile /opt/git/.htpasswd
    Require valid-user
    Order deny,allow
    Deny from env=AUTHREQUIRED
    Satisfy any

create .htpasswd

htpasswd -c /opt/git/.htpasswd  user01

Client Side

middleware/version-control/git/crete-remote-repo.txt ยท Last modified: 2021/03/28 by admin

Page Tools