
Pull From Github in Git
π How to Pull from GitHub
Pulling from GitHub means fetching the latest changes from the remote repository and merging them into your local branch.
π Steps to Pull Changes from GitHub
1οΈβ£ Navigate to Your Repository
If you havenβt cloned the repo yet, do so:
git clone https://github.com/your-username/repository-name.gitcd repository-name
2οΈβ£ Check Your Current Branch
Before pulling, make sure you're on the correct branch:
git branch
If needed, switch branches:
git checkout main
3οΈβ£ Fetch the Latest Changes
To get the latest updates without merging:
git fetch origin
4οΈβ£ Pull Changes from GitHub
To update your local branch with remote changes:
git pull origin main
For another branch:
git pull origin feature-branch
5οΈβ£ Resolve Merge Conflicts (If Any)
If Git shows a merge conflict:
- Open the conflicting file.
- Manually edit the conflict markers (
<<<<<<<
,=======
,>>>>>>>
). - Stage the resolved file:
git add filename
- Commit the resolution:
git commit -m "Resolved merge conflict"
π₯ Example Workflow
git checkout maingit pull origin main
π― Summary
β
Switch to the correct branch β git checkout branch-name
β
Fetch latest changes β git fetch origin
β
Pull updates β git pull origin branch-name
β
Resolve conflicts if necessary