~/
hackweb.dev
Pushing and Pulling
Quiz
⌘K
...
~/
/tutorials
/git/git-push-pull/edit
~ Contribute
Suggest a correction or improvement. The author reviews it before it goes live.
Loading...
Comment
0 / 300
Typo
Grammar
Broken link
Clarify
Code
en/tutorials/git/11git-push-pull
Write
Preview
Diff
# Pushing and Pulling Push sends your commits to a remote. Pull fetches and integrates changes from a remote. ## Pushing Changes ```bash git push origin main ``` Sends your local `main` commits to the `origin` remote. ## Set Upstream ```bash git push -u origin main ``` The `-u` flag sets `origin main` as the default upstream. After this, just run `git push`. ## Pulling Changes ```bash git pull origin main ``` Fetches and merges remote changes into your current branch. ## Pull with Rebase ```bash git pull --rebase origin main ``` Replays your local commits on top of the fetched changes instead of creating a merge commit. ## What `--set-upstream` Does ```bash git push --set-upstream origin feature ``` Links your local `feature` branch to the remote `feature` branch. After this, `git push` and `git pull` work without arguments. ## Best Practices - Pull before pushing to avoid conflicts - Use `--rebase` for cleaner history - Set upstream once, then use shorthand commands - Push regularly to share progress with your team ## Common Mistakes - Forgetting to pull before push - Pushing force to shared branches - Not setting upstream and getting errors - Pushing sensitive data accidentally
No changes yet
Reset to original
Submit suggestion
cancel