cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:version-control:git:crete-remote-repo



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

httpd.conf

SetEnv GIT_PROJECT_ROOT /opt/git
SetEnv GIT_HTTP_EXPORT_ALL
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
</Files>

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