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

Git GitLab Introduction

GitLab आपके Git projects के लिए एक built-in robot factory वाला एक clubhouse है जो हर बार save करने पर automatically आपका काम test और deliver करता है।
Syntax
bash
git remote add origin https://gitlab.com/user/repo.git
git clone https://gitlab.com/user/repo.git

GitLab क्या है?

GitLab integrated DevOps tooling के आसपास बना एक web-based Git repository host है, खासतौर पर अपने खुद के CI/CD pipelines, issue tracking, और container registry, सब एक product में। आप एक local repository को इससे उसी git remote add workflow से connect करते हैं जो आप किसी दूसरे host के लिए इस्तेमाल करते, इसलिए आपके everyday Git commands में कुछ नहीं बदलता।

उदाहरण: What is GitLab?

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

GitLab से Clone करना

एक GitLab project clone करना HTTPS (username/password या personal access token पूछता है) या SSH (आपके account पर registered एक key pair इस्तेमाल करता है, कोई password prompt नहीं) दोनों पर काम करता है। एक बार cloned होने पर, project किसी भी local Git repository जैसा behave करता है — GitLab सिर्फ तभी फिर मायने रखता है जब आप push, pull, या एक merge request खोलें।

उदाहरण: Cloning from GitLab

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

GitLab CI/CD Basics

आपके project root पर एक .gitlab-ci.yml file एक या ज़्यादा pipeline stages (build, test, deploy) define करती है जिन्हें GitLab हर push पर automatically चलाता है। यही एक team को एक टूटी हुई build या failing test को एक commit के मिनटों के अंदर पकड़ने देता है, इसे बाद में एक manual release के दौरान discover करने के बजाय।

उदाहरण: GitLab CI/CD Basics

bash
echo "stages:\n  - build\n  - test\n  - deploy" > .gitlab-ci.yml

Merge Requests के साथ काम करना

GitLab का Merge Request functionally GitHub के Pull Request जैसा ही idea है: एक feature branch push करें, फिर merge करने से पहले review comments और approval rules की gunjaish के साथ इसे एक target branch में merge करने की माँग वाला एक request खोलें। renamed term दोनों platforms के बीच switch करने वाले लोगों को confuse करता है।

उदाहरण: Working with Merge Requests

bash
git checkout -b add-search-bar
git push -u origin add-search-bar

GitLab पर Forking

GitLab पर Forking किसी project (इसकी पूरी history सहित) को आपके अपने namespace में copy करता है, ताकि आप original पर write access की ज़रूरत के बिना changes कर सकें। फिर आप अपने fork में commits push करते हैं और source project को वापस एक merge request खोलते हैं, जो किसी ऐसी repository में contribute करने का standard workflow है जो आपकी नहीं है।

उदाहरण: Forking on GitLab

bash
git clone https://gitlab.com/yourname/repo.git
git push 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. HTTPS पर अपना GitLab account password इस्तेमाल करना जब एक personal access token या SSH key चाहिए हो।
  2. leading dot के बिना pipeline file को gitlab-ci.yml नाम देना, ताकि GitLab कोई pipeline न चलाए; इसे .gitlab-ci.yml होना ज़रूरी है।
  3. यह मान लेना कि बिना किसी configuration के GitLab CI किसी भी push पर चलता है, जबकि jobs सिर्फ तभी चलती हैं जब .gitlab-ci.yml file उन्हें define करे।

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.