Ubuntu 22.04
Sponsored Link

Git : HTTP के माध्यम से रिपोज़ तक पहुंच2023/09/27

 
HTTP के माध्यम से रिपोज़ तक पहुंचने के लिए कॉन्फ़िगर करें।
[1]
[2]
[3] Git रिपॉजिटरी तक पहुंचने के लिए Apache2 को कॉन्फ़िगर करें।
उदाहरण के लिए, Git रिपॉजिटरी के लिए रूट डायरेक्टरी के रूप में [/var/lib/git] सेट करें।
root@dlp:~#
vi /etc/apache2/conf-available/git.conf
# नया निर्माण

SetEnv GIT_PROJECT_ROOT /var/lib/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

<Location /git>
    Options ExecCGI
    AuthName "Git for HTTP"
    AuthType Basic
    AuthUserFile /etc/apache2/.htpasswd
    Require valid-user
</Location>

root@dlp:~#
a2enconf git

root@dlp:~#
a2enmod cgi rewrite

root@dlp:~#
systemctl restart apache2
# उपयोगकर्ता जोड़ें: [-c] के साथ एक नई फ़ाइल बनाएं

root@dlp:~#
htpasswd -c /etc/apache2/.htpasswd ubuntu

New password:    
# सांकेतिक शब्द लगना

Re-type new password:
Adding password for user ubuntu
[4] रूट डायरेक्टरी के अंतर्गत एक Git रिपॉजिटरी बनाएं।
root@dlp:~#
cd /var/lib/git

root@dlp:/var/lib/git#
mkdir project01.git

root@dlp:/var/lib/git#
cd project01.git

root@dlp:/var/lib/git/project01.git#
git init --bare --shared

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty shared Git repository in /var/lib/git/project01.git/

root@dlp:/var/lib/git/project01.git#
chgrp -R www-data /var/lib/git/project01.git
[5] HTTP के माध्यम से Git रिपॉजिटरी तक पहुंचने के लिए सत्यापित करें।
jammy@node01:~$
mkdir work

jammy@node01:~$
cd work
# उपयोगकर्ता को आपने [3] पर htpasswd के साथ जोड़ा है

jammy@node01:~/work$
git clone https://ubuntu@dlp.srv.world/git/project01.git

Cloning into 'project01'...
Password for 'https://ubuntu@dlp.srv.world':   # htpasswd में उपयोगकर्ता का पासवर्ड
warning: You appear to have cloned an empty repository.

jammy@node01:~/work$
cd project01

jammy@node01:~/work/project01$
git config --global user.name "Server World"

jammy@node01:~/work/project01$
git config --global user.email "jammy@node01.srv.world"
jammy@node01:~/work/project01$
echo testfile > testfile1.txt

jammy@node01:~/work/project01$
git add testfile1.txt

jammy@node01:~/work/project01$
git commit testfile1.txt -m "Initial Commit"

[master (root-commit) 754e002] Initial Commit
 1 file changed, 1 insertion(+)
 create mode 100644 testfile1.txt

jammy@node01:~/work/project01$
git remote -v

origin  https://ubuntu@dlp.srv.world/git/project01.git (fetch)
origin  https://ubuntu@dlp.srv.world/git/project01.git (push)

jammy@node01:~/work/project01$
git push origin master

Password for 'https://ubuntu@dlp.srv.world':
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 235 bytes | 235.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://dlp.srv.world/git/project01.git
 * [new branch]      master -> master

jammy@node01:~/work/project01$
git ls-files

testfile1.txt
मिलान सामग्री