Git : स्थापित करना2024/07/24 |
Git को स्थापित और कॉन्फ़िगर करें जो कि संशोधन नियंत्रण प्रणाली है। |
|
[1] | Git इंस्टॉल करें। |
root@dlp:~# apt -y install git
|
[2] | इसे किसी भी आम यूजर के लिए इस्तेमाल करना संभव है। उदाहरण के लिए, लोकलहोस्ट पर किसी उपयोगकर्ता के साथ एक रिपॉजिटरी बनाएं। |
# एक खाली भंडार बनाएं ubuntu@dlp:~$ mkdir project.git ubuntu@dlp:~$ cd project.git ubuntu@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/ubuntu/project.git/
ubuntu@dlp:~/project.git$
# एक कार्यशील निर्देशिका बनाएं ubuntu@dlp:~$ mkdir work ubuntu@dlp:~$ cd work ubuntu@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/ubuntu/work/.git/ # उपयोगकर्ता नाम और ईमेल पता सेट करें ubuntu@dlp:~/work$ git config --global user.name "Server World" ubuntu@dlp:~/work$ git config --global user.email "serverworld@dlp.srv.world"
# एक परीक्षण फ़ाइल बनाएं और इसे रिपॉजिटरी पर लागू करें ubuntu@dlp:~/work$ echo testfile > testfile1.txt ubuntu@dlp:~/work$ git add testfile1.txt ubuntu@dlp:~/work$ git commit testfile1.txt -m "Initial Commit" [master (root-commit) 0843ab5] Initial Commit 1 file changed, 1 insertion(+) create mode 100644 testfile1.txtubuntu@dlp:~/work$ git push /home/ubuntu/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/ubuntu/project.git * [new branch] master -> masterubuntu@dlp:~/work$ git ls-files testfile1.txt # रिपॉजिटरी में कोई भी नाम सेट करें ubuntu@dlp:~/work$ git remote add origin /home/ubuntu/project.git ubuntu@dlp:~/work$ git remote -v origin /home/ubuntu/project.git (fetch) origin /home/ubuntu/project.git (push)ubuntu@dlp:~/work$ git remote show origin * remote origin Fetch URL: /home/ubuntu/project.git Push URL: /home/ubuntu/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) # आपके द्वारा ऊपर निर्धारित नाम से पुश करना संभव है ubuntu@dlp:~/work$ echo testfile > testfile2.txt ubuntu@dlp:~/work$ git add testfile2.txt ubuntu@dlp:~/work$ git commit testfile2.txt -m "New Commit testfile2.txt" [master 09647b6] New Commit testfile2.txt 1 file changed, 1 insertion(+) create mode 100644 testfile2.txtubuntu@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 To /home/ubuntu/project.git 0843ab5..09647b6 master -> master # मौजूदा रिपॉजिटरी को खाली कार्यशील निर्देशिका में क्लोन करने के मामले के लिए ubuntu@dlp:~/work$ mkdir ~/work2 ubuntu@dlp:~/work$ cd ~/work2 ubuntu@dlp:~/work2$ git clone /home/ubuntu/project.git Cloning into 'project'... done.ubuntu@dlp:~/work2$ total 12 drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 23 23:56 ./ drwxr-x--- 7 ubuntu ubuntu 4096 Jul 23 23:56 ../ drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 23 23:56 project/ubuntu@dlp:~/work2$ ll project total 20 drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 23 23:56 ./ drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 23 23:56 ../ drwxrwxr-x 8 ubuntu ubuntu 4096 Jul 23 23:56 .git/ -rw-rw-r-- 1 ubuntu ubuntu 9 Jul 23 23:56 testfile1.txt -rw-rw-r-- 1 ubuntu ubuntu 9 Jul 23 23:56 testfile2.txt |
Sponsored Link |
|