FreeBSD 14
Sponsored Link

Git : Install2024/09/13

 

Install and Configure Git which is the Revision Control System.

[1] Install Git.
root@dlp:~ #
pkg install -y git
[2] It's possible to use for any common user.
For example, Create a repository with a user on localhost.
# create an empty repository

freebsd@dlp:~ $
mkdir project.git

freebsd@dlp:~ $
cd project.git

freebsd@dlp:~/project.git $
git init --bare

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/freebsd/project.git/

freebsd@dlp:~/project.git $
cd
# create a working directory

freebsd@dlp:~ $
mkdir work

freebsd@dlp:~ $
cd work

freebsd@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/freebsd/work/.git/

# set username and email address

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

freebsd@dlp:~/work $
git config --global user.email "serverworld@dlp.srv.world"
# create a test file and apply it to repository

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

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

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

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

freebsd@dlp:~/work $
git push /home/freebsd/project.git master

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

freebsd@dlp:~/work $
git ls-files

testfile1.txt

# set any name to the repository

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

freebsd@dlp:~/work $
git remote -v

origin  /home/freebsd/project.git (fetch)
origin  /home/freebsd/project.git (push)

freebsd@dlp:~/work $
git remote show origin

* remote origin
  Fetch URL: /home/freebsd/project.git
  Push  URL: /home/freebsd/project.git
  HEAD branch: master
  Remote branch:
    master new (next fetch will store in remotes/origin)
  Local ref configured for 'git push':
    master pushes to master (up to date)

# possible to push with the name you set above

freebsd@dlp:~/work $
echo testfile > testfile2.txt

freebsd@dlp:~/work $
git add testfile2.txt

freebsd@dlp:~/work $
git commit testfile2.txt -m "New Commit testfile2.txt"

[master a1e474d] New Commit testfile2.txt
 1 file changed, 1 insertion(+)
 create mode 100644 testfile2.txt

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

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 256 bytes | 256.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To /home/freebsd/project.git
   ae100aa..a1e474d  master -> master

# for the case to clone existing repository to empty working directory

freebsd@dlp:~/work $
mkdir ~/work2

freebsd@dlp:~/work $
cd ~/work2

freebsd@dlp:~/work2 $
git clone /home/freebsd/project.git

Cloning into 'project'...
done.

freebsd@dlp:~/work2 $
ls -l

total 1
drwxr-xr-x  3 freebsd freebsd 5 Sep 13 11:20 project

freebsd@dlp:~/work2 $
ls -la project

total 11
drwxr-xr-x  3 freebsd freebsd  5 Sep 13 11:20 .
drwxr-xr-x  3 freebsd freebsd  3 Sep 13 11:20 ..
drwxr-xr-x  8 freebsd freebsd 13 Sep 13 11:20 .git
-rw-r--r--  1 freebsd freebsd  9 Sep 13 11:20 testfile1.txt
-rw-r--r--  1 freebsd freebsd  9 Sep 13 11:20 testfile2.txt
Matched Content