You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git status -> hme yeh pta chl jata h ki kitni files trace ya add h repo m
bs whi commits github pr show honge jo push krenge hm
agr hmne commit ko push nhi kiya toh vo locally apne computer pr save hoga github pe nhi
.gitignore hmne direct github se hi bnai h and vscode m us file ko lane ki liye (git pull origin main) commond ko use kiya h
agr hme koi specefic file prevent krana h commit krne se repo m toh hm usse gitignore file m daal denge
merging branches in git
git branch (branch's name) write this in terminal to make a new branch apart from our main branch ( the new branch which will we crete is a copy of our main branch only)
ab agr hm terminal m git branch commond likhenge toh hme main branch ke alawa bhi ek aur branch show hogi jo hmmne create ki h
suppose-> branch name is devloper a
jb hm git branch likhene toh hme 2 branches show hogi terminal m (main aur devloper a) but main green se show hogi jiska mtlb yeh h ki abhi hm main m present h aur hmne jo bhi coding kri yeh code m changes kiye, toh devloper a branch m n hokr vo changes main branch m hojyenge jo ki prblm h
isliye hm terminal m ek command likhenge (git checkout branch name)
exm-> git checkout devloper a
ab devloper a m present honge hm and ab jo changes honge vo devloper a branch m hi honge jo ki shi h and devloper a green se show hoga terminal m
phele ke saare changes commit krne ke baad branches switch krni hoti h
jb hm branch change krlenge tb apna code ya code m changes krana h vo sb krlo
then use git add file command then commit the code
then again use git checkout command (git checkout main) ab jo hmne code devloper a branch m likha tha vo gyab ho jyenga uss code ko apne main branch m merge krane ke liye
git commnd-> git merge branch's name
agr merge krte time koi issue aagye toh use(git commit -m "resolve merge conflict") after manually reviewing the file
then delete the copy of main branch which we have created (devloper a branch) uska command net pe mil jyega anyways it's not neccesory but a good practice
just type delete local branch on google copy the command use it
at last push the code to github if you want
git pull
agr kisi se direct repo se change kiya h code toh phele us code ko pull kro git pull origin main se then fir changes waghera krke commit and push kro
git log --oneline — commit history dekhne ke liye (clean format)
git diff — commit se pehle exactly kya changes hue dekh sakta hai
refer to github commands pdf also
agr merge krte time conflict aaye toh:
step 1: file manually edit karo — VS Code conflict wali jagah highlight karta hai
<<<<<<< HEAD (main branch ka code)
======= (divider)
>>>>>>> developer-a (incoming branch ka code)
VS Code m upar buttons aate h: Accept Current Change / Accept Incoming Change / Accept Both Changes
step 2: git add
step 3: git commit -m "resolve merge conflict"
automatically resolve nahi hota — kaunsa code rakhna hai ye tera decision hai
When to use git pull
1. Someone else has pushed new code to the repository.
→ Use git pull to get those changes on your local machine.
2. You pushed code from another laptop/PC.
→ Use git pull on your current device to sync the latest changes.
3. You edited files directly on GitHub (e.g., README.md).
→ Use git pull to bring those changes into your local repository.
4. You're working on a team project.
→ Always git pull before starting work to avoid conflicts and stay up to date.