Merges, Pull Requests, and Remote Branches
Summary
This note explains what happens after work is done on a branch: how changes are merged, how pull requests fit into the workflow, and how remote branches relate to your local ones. This is the point where individual Git work turns into collaboration or at least into a cleaner review process.
Why this matters
- most real Git workflows do not end at
git commit - merges and pull requests are how work is reviewed, integrated, and shared
- remote branches are often where confusion starts if the local and remote mental model is weak
Environment / Scope
| Item | Value |
|---|---|
| Topic | Git collaboration model |
| Best use for this note | understanding branch integration |
| Main focus | merge, pull request, local vs remote branch |
| Safe to practise? | yes, in a throwaway repo |
Key concepts
- Merge - combining changes from one branch into another
- Pull request - a review and merge workflow around branch changes, usually on GitHub
- Local branch - a branch that exists in your local repository
- Remote branch - a branch that exists on the remote repository
- Tracking branch - a local branch associated with a specific remote branch
Mental model
Think about this flow:
local feature branch
-> push to remote feature branch
-> open pull request
-> review and merge into mainThis means:
- you do work locally on a branch
- you push that branch to the remote
- the pull request represents discussion and review
- merging brings the work into the target branch, usually
main
Everyday workflow
| Step | Typical command or action | Meaning |
|---|---|---|
| Push feature branch | git push -u origin feature-x | create or update the remote branch |
| Open PR | GitHub UI | request review and propose merge |
| Update branch | git push | send more commits to the same branch |
| Merge | GitHub UI or git merge | integrate branch work |
| Clean up | delete branch | remove no-longer-needed branch after merge |
Common misunderstandings
| Misunderstanding | Better explanation |
|---|---|
| ”A pull request is the merge” | the PR is the review process around the proposed merge |
| ”Pushing a branch means it is already in main” | pushing only updates the remote branch, not the target branch |
| ”Remote branch and local branch are the same thing” | they are related, but they are still separate states |
| ”Merge problems mean Git is broken” | often it just means the histories changed in parallel and need reconciliation |
Verification
| Check | Expected result |
|---|---|
git branch | shows your local branches |
git branch -r | shows remote branches |
git status | shows current branch and tracking info |
git log --oneline --graph --all | shows how branches relate in history |
Pitfalls / Troubleshooting
| Problem | Likely cause | What to check |
|---|---|---|
| Branch exists locally but not remotely | not pushed yet | git push -u origin ... |
| PR does not include expected commits | wrong branch or missing push | current branch, remote branch, recent commits |
| Merge is confusing | weak branch history mental model | git log --oneline --graph --all |
| Old branches pile up | no cleanup habit | branches after merge |
Practical rule
A pull request is usually easier to understand if you think of it as “please review this branch before it becomes part of main”.
Key takeaways
- merge is about integrating branch history
- a pull request is the workflow around review and integration
- local and remote branches are related, but they are not the same thing