← Back to Git Course | Chapter 4: Remote Repositories | Lesson 8 of 11

Git GitHub Introduction

GitHub code के लिए एक विशाल playground जैसा है, जहाँ आप अपने projects online store करते हैं और चैट करते हैं, changes suggest करते हैं और एक-दूसरे की मदद करते हैं।
Syntax
bash
git remote add origin https://github.com/user/repo.git
git clone https://github.com/user/repo.git

GitHub क्या है?

GitHub Git repositories के लिए एक web-based hosting platform है जो raw Git के ऊपर collaboration tools -- issues, pull requests, code review -- add करता है। आप एक local repository को git remote add इस्तेमाल करके किसी भी दूसरे remote जैसे ही इससे connect करते हैं।

उदाहरण: What is GitHub?

bash
git remote add origin https://github.com/user/repo.git

GitHub से Clone करना

GitHub पर कोई भी public repository को इसके HTTPS URL या इसके SSH URL से कोई भी clone कर सकता है -- HTTPS शुरुआत में set up करना simpler है, जबकि SSH आपकी key configured होने के बाद credentials दोबारा enter करने से बचाता है।

उदाहरण: Cloning from GitHub

bash
git clone https://github.com/user/repo.git
git clone [email protected]:user/repo.git

Forking और Pull Requests

Forking आपके GitHub account के तहत किसी और की repository की आपकी अपनी personal copy बनाता है; original को अपने fork के origin के साथ एक upstream remote की तरह add करना आपको समय के साथ original project के updates खींचते रहने देता है।

उदाहरण: Forking and Pull Requests

bash
git remote add upstream https://github.com/original/repo.git
git fetch upstream

Personal Access Tokens

2021 से, GitHub को HTTPS पर command-line authentication के लिए आपके account password के बजाय एक Personal Access Token चाहिए -- आप इसे GitHub की settings में generate करते हैं और Git को इसे password जैसा इस्तेमाल करने के लिए configure करते हैं।

उदाहरण: Personal Access Tokens

bash
git clone https://<token>@github.com/user/repo.git

एक मौजूदा Project Link करना

एक ऐसा project publish करने के लिए जो पहले से locally exist करता है, हमेशा की तरह git init, git add, और git commit चलाएँ, फिर GitHub पर एक empty repository बनाएँ, इसे एक remote की तरह add करें, और push करें -- GitHub को उस final push तक कभी आपका code देखने की ज़रूरत नहीं।

उदाहरण: Linking an Existing Project

bash
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin main
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. Git और GitHub को confuse करना, जबकि GitHub एक hosting service है और Git tool है।
  2. HTTPS से clone करना और एक password माँगे जाने पर, जिसे GitHub अब accept नहीं करता; एक personal access token या SSH इस्तेमाल करें।
  3. एक fork की files edit करना और original repository के बदलने की उम्मीद करना, जबकि आपको एक pull request खोलना ज़रूरी है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.