← Back to Git Course | Chapter 8: Best Practices | Lesson 5 of 6

Git Interview Questions

Git interview questions basics पर एक quiz जैसे हैं, जैसे tool Git और इसे hosting करने वाली website GitHub के बीच अंतर।

Git और GitHub में क्या अंतर है?

Git version control software खुद है — यह पूरी तरह offline काम करता है और किसी server की ज़रूरत नहीं। GitHub Git के ऊपर बनी एक company की hosting service है, एक web UI, pull requests, issue tracking, और repositories store करने के लिए एक remote जगह add करते हुए — आप कभी GitHub को touch किए बिना पूरी तरह Git इस्तेमाल कर सकते हैं।

उदाहरण: What is the difference between Git and GitHub?

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

Merge और Rebase में क्या अंतर है?

एक merge दो parents वाली एक नई commit बनाता है, यह exact shape preserve करते हुए कि दोनों branches की histories actually कैसे हुईं, हर intermediate commit सहित। एक rebase आपकी commits को एक-एक करके एक नए base पर replay करता है, बिना merge commit के एक straight line produce करते हुए — पढ़ने में cleaner, लेकिन यह commit hashes rewrite करता है, जो एक ऐसी branch पर unsafe है जिसे दूसरे पहले से pull कर चुके हैं।

उदाहरण: What is the difference between merge and rebase?

bash
git merge feature-x
# vs.
git rebase main

git stash क्या करता है?

git stash आपके uncommitted changes (staged और unstaged) का एक stack पर snapshot लेता है और आपकी working directory को last commit से match करने पर reset करता है, आपको बिना unfinished काम commit किए tasks switch करने के लिए एक clean slate देते हुए — आप बाद में git stash pop से changes वापस लाते हैं।

उदाहरण: What does git stash do?

bash
git stash
git stash pop

एक Detached HEAD State क्या है?

एक branch name के बजाय सीधे एक commit hash या tag checkout करना HEAD को एक "detached" state में डाल देता है — आप किसी branch की tip के बजाय एक specific commit पर होते हैं, इसलिए वहाँ आपकी बनाई कोई भी नई commits किसी branch से attached नहीं होतीं और कुछ और checkout करते ही खो सकती हैं, जब तक आप पहले उस point से एक branch न बनाएँ।

उदाहरण: What is a detached HEAD state?

bash
git checkout a1b2c3d

git cherry-pick क्या है?

git cherry-pick <hash> repository की history में कहीं से भी एक specific commit लेता है — अक्सर एक दूसरी branch से — और इसे आपकी current branch पर एक नई commit की तरह replay करता है, उस branch की दूसरी, unrelated commits merge किए बिना एक single fix लाने के लिए उपयोगी।

उदाहरण: What is git cherry-pick?

bash
git cherry-pick a1b2c3d
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 same चीज़ हैं, जबकि Git tool है और GitHub एक hosting service।
  2. git rebase को सिर्फ एक और merge की तरह describe करना, यह note किए बिना कि यह commits rewrite करता है और shared branches पर इस्तेमाल नहीं होना चाहिए।
  3. git stash को changes permanently save करने की तरह explain करना, जबकि यह एक temporary stack है और untracked files को -u चाहिए।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

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.