Git : Install2021/06/18 |
Install and Configure Git which is the Revision Control System.
|
|
[1] | Install Git. |
[root@dlp ~]# dnf -y install 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 [cent@dlp ~]$ mkdir project.git [cent@dlp ~]$ cd project.git [cent@dlp project.git]$ git init --bare Initialized empty Git repository in /home/cent/project.git/
[cent@dlp ~]$
# create a working directory [cent@dlp ~]$ mkdir work [cent@dlp ~]$ cd work [cent@dlp work]$ git init Initialized empty Git repository in /home/cent/work/.git/ # set username and email address [cent@dlp work]$ git config --global user.name "Server World" [cent@dlp work]$ git config --global user.email "cent@dlp.srv.world"
# create a test file and apply it to repository [cent@dlp work]$ echo testfile > testfile1.txt [cent@dlp work]$ git add testfile1.txt [cent@dlp work]$ git commit testfile1.txt -m "Initial Commit" [master (root-commit) 6d207bd] Initial Commit 1 file changed, 1 insertion(+) create mode 100644 testfile1.txt[cent@dlp work]$ git push /home/cent/project.git master Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 232 bytes | 232.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 To /home/cent/project.git * [new branch] master -> master[cent@dlp work]$ git ls-files testfile1.txt # set any name to the repository [cent@dlp work]$ git remote add origin /home/cent/project.git [cent@dlp work]$ git remote -v origin /home/cent/project.git (fetch) origin /home/cent/project.git (push)[cent@dlp work]$ git remote show origin * remote origin Fetch URL: /home/cent/project.git Push URL: /home/cent/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 [cent@dlp work]$ echo testfile > testfile2.txt [cent@dlp work]$ git add testfile2.txt [cent@dlp work]$ git commit testfile2.txt -m "New Commit testfile2.txt" [master 2d27fe9] New Commit testfile2.txt 1 file changed, 1 insertion(+) create mode 100644 testfile2.txt[cent@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), 258 bytes | 258.00 KiB/s, done. Total 2 (delta 0), reused 0 (delta 0), pack-reused 0 To /home/cent/project.git 6d207bd..2d27fe9 master -> master # for the case to clone existing repository to empty working directory [cent@dlp work]$ mkdir ~/work2 [cent@dlp work]$ cd ~/work2 [cent@dlp work2]$ git clone /home/cent/project.git Cloning into 'project'... done.[cent@dlp work2]$ total 0 drwxrwxr-x. 3 cent cent 60 Jun 18 00:23 project[cent@dlp work2]$ ll project total 8 -rw-rw-r--. 1 cent cent 9 Jun 18 00:23 testfile1.txt -rw-rw-r--. 1 cent cent 9 Jun 18 00:23 testfile2.txt |
Sponsored Link |