Git Interview Questions
In this page:
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?
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?
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?
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?
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?
git cherry-pick a1b2c3d
- यह कहना कि Git और GitHub same चीज़ हैं, जबकि Git tool है और GitHub एक hosting service।
git rebaseको सिर्फ एक और merge की तरह describe करना, यह note किए बिना कि यह commits rewrite करता है और shared branches पर इस्तेमाल नहीं होना चाहिए।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: