Git Version Control – Complete GitHub Workflow Guide
Git aaj kal har developer ke liye essential hota hai. Code management aur collaboration ke liye Git use hote hain. GitHub Git ka sabse popular platform hota hai. Version control system understanding modern development mein must-have skill hoti hai.
Git Kya Hota Hai
Git version control system hota hai. Jab aap code mein changes karte ho to Git unhe track karta hai. Later aap kisi bhi previous version par ja sakte ho. Git se team collaboration easy hota hai. Ek project par multiple developers kaam kar sakte hain aur conflicts avoid kar sakte hain efficiently.
Git distributed system hota hai – har developer ke paas complete history hota hai locally.
Git Install Karo
Pehle Git install karna padta hai apne computer mein. Git website se download kar sakte ho ya package manager se install kar sakte ho. Linux: sudo apt-get install git, Mac: brew install git, Windows: installer se install. Git install karne ke baad terminal mein “git –version” likho confirm karne ke liye.
Configuration: git config –global user.name “Your Name” aur git config –global user.email “your@email.com”
Local Repository Setup
Project folder mein “git init” command dote ho to ek new Git repository create ho jati hai. Ye .git folder create karta hai jo sab version history store karta hai internally. Repository banate hue project version control mein aa jata hai. .git folder typically hidden folder hota hai.
Repository local machine par isolated environment provide karta hai independent development ke liye.
Staging Area Samjhiye
Git mein changes first staging area mein jate hain. “git add” command use karke files ko staging area mein add karte ho. Staging area se aap selectively choose kar sakte ho ke konse files commit karne hain. Partial commits karte hue related changes group kar sakte ho logically.
“git add .” sab files add karta hai, “git add filename” specific file add karta hai.
Commits Likho
“git commit” command use karke staged changes ko repository mein save karte ho. Commit ke sath ek message likho jo changes describe karey. Good commit messages future mein project ko understand karne mein madad karte hain. Descriptive messages team communication improve karte hain.
“git commit -m ‘Add user authentication feature'” – meaningful message likho every commit mein.
Branches Banao
Branches separate development lines hote hain. Main branch hota hai production code aur development branch hota hai new features ke liye. Branches se multiple features parallel mein develop kar sakte ho. Feature branches separate concerns isolate karte hain.
“git branch feature-name” se new branch banata ho. Branches collaboration mein critical hote hain.
Branch Switching
“git checkout” command se branches ke beech switch karte ho. “git switch” bhi use kar sakte ho newer versions mein – yeh clearer syntax hota hai. Branch switch karte hue current changes save ho jate hain branch ke sath automatically. Uncommitted changes losses avoid karte ho switching se pehle commit karke.
Branch switching fast aur non-destructive hota hai Git architecture se.
Merging Branches
Jab feature complete ho jaye to branch ko main mein merge karte ho. “git merge” command use karte ho. Sometimes merge conflicts hote hain jo manually resolve karne padta hain. Conflicts resolve karte hue both changes carefully review karte ho.
Merge strategy (fast-forward vs three-way merge) automatic hota hai Git ke liye based on history.
GitHub Pe Push Karo
GitHub account banate hue repository create karte ho. Local repository ko GitHub se connect karte ho “git remote add origin” use karke. “git push” command use karke local code GitHub par upload karte ho. Remote repository backup provide karta hai aur team collaboration enable karta hai.
“git push origin branch-name” specific branch push karta hai.
Pull Requests Likho
GitHub par pull request banate hue review ke liye code submit karte ho. Team members code review karte hain aur comments dete hain. Pull requests collaboration aur code quality assurance ka hissa hote hain. Discussion happen karta hai pull request mein changes merge se pehle.
Pull request templates team standards enforce karte hain.
Changes Pull Karo
“git pull” command use karke remote repository se latest changes local machine par download karte ho. Team mein kaam karte hue regularly pull karte ho latest code get karne ke liye. Pull fetching aur merging combine karta hai automatically.
“git fetch” sirf download karta hai merge kiye bina – useful sometimes review ke liye.
Merge Conflicts Resolve Karo
Jab do branches same file mein changes karte hain to merge conflict hote hain. Manual tarike se conflict markers ko remove karke conflict resolve karte ho. VS Code aur other editors merge conflict resolution UI provide karte hain. Both changes carefully evaluate karte ho conflict resolution mein.
Conflicts handle karna Git ke important part hota hai team development mein.
Stash Use Karo
“git stash” temporary changes ko save karta hai. Jab aap branch switch karna chahte ho lekin current changes commit na karna chahte ho tab stash use karte ho. Later “git stash pop” se stashed changes wapas le sakte ho. Stash clean working directory maintain karte hue branch switching enable karta hai.
Multiple stashes manage kar sakte ho “git stash list” se.
History Dekhte Raho
“git log” command se commit history dekh sakte ho. Commit messages, dates, authors – sab info milta hai. History mein errors find karne ke liye git blame aur git bisect use kar sakte ho. Git log –oneline concise view provide karta hai.
History understanding project evolution track karte hue helpful hota hai.
Undoing Changes
“git revert” commit ko undo karta hai new commit create karke. “git reset” working directory aur staging area change karta hai. “git restore” specific files changes discard karta hai. Careful ho undo operations mein – unintended changes prevent karte hue.
Undo operations git history mein recorded hote hain traceability ke liye.
Conclusion
Git sikhna developer ka basic duty hota hai. GitHub par projects host karte hue portfolio bna sakte ho. Version control expertise team collaboration enable karte hue professional development enable karte hain. Continuous practice karte raho Git commands ko aur workflows ko. Git mastery professional development career ke liye essential hota hai aaj kal.
Strong Git knowledge se team collaboration smooth aur organized ban jata hai effectively.