Share work with remotes
Clone repositories and understand fetch, pull and push.
- Use remote commands to synchronize without confusing local and hosted history.
A remote is a named URL for another copy of a repository, often hosted on a service. git fetch downloads commits and updates remote-tracking references without changing your current branch. git pull fetches and then integrates; git push sends your local commits to a remote.
1git clone https://example.com/team/app.git
2cd app
3git remote -v
4
5git fetch origin
6git log --oneline main..origin/main
7
8git push -u origin feature/profileorigin https://example.com/team/app.git (fetch) origin https://example.com/team/app.git (push) # commits on origin/main not yet in main branch 'feature/profile' set up to track 'origin/feature/profile'
An upstream branch links a local branch to its remote counterpart so commands such as git pull and git push can infer a destination. Always inspect what you are pushing, especially if the remote branch has moved.
Key takeaways
git clonecreates a local copy of a remote repository.git fetchdownloads updates;git pullalso integrates them.git pushsends commits to a remote, and-usets an upstream on first push.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…