FreeBSD 14
Sponsored Link

Git : Create Shared Repositories2024/09/13

 

Create Shared Repositories which some users can use.

[1] Create a group for share and set users in the group.
# create a group

root@dlp:~ #
pw groupadd project01
# add users to the group

root@dlp:~ #
pw groupmod project01 -m freebsd

root@dlp:~ #
pw groupmod project01 -m netbsd
[2] Create a shared repository with a user.
# create a directory for repository and change group

freebsd@dlp:~ $
mkdir project01.git

freebsd@dlp:~ $
chgrp project01 project01.git

freebsd@dlp:~ $
cd project01.git
freebsd@dlp:~/project01.git $
chmod 755 /home/freebsd

# set empty share repository

freebsd@dlp:~/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 /home/freebsd/project01.git/
[3] Verify to use repository with users who are in the group for share added in [1].
netbsd@dlp:~ $
mkdir work

netbsd@dlp:~ $
cd work
netbsd@dlp:~/work $
git init

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 Git repository in /home/netbsd/work/.git/

netbsd@dlp:~/work $
git config --global user.name "Server World"

netbsd@dlp:~/work $
git config --global user.email "netbsd@dlp.srv.world"

netbsd@dlp:~/work $
git config --global --add safe.directory /home/freebsd/project01.git
# create a test file and push it to repository

netbsd@dlp:~/work $
echo testfile > testfile1.txt

netbsd@dlp:~/work $
git add testfile1.txt

netbsd@dlp:~/work $
git commit testfile1.txt -m "Initial Commit"

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

netbsd@dlp:~/work $
git remote add origin /home/freebsd/project01.git

netbsd@dlp:~/work $
git push origin master

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 233 bytes | 233.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To /home/freebsd/project01.git
 * [new branch]      master -> master
Matched Content