appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

Remotes, GitHub and collaboration

Lesson 3 of 49 minBeginner

Clone, push and pull, and the pull request workflow.

A remote is a copy of the repository hosted elsewhere, such as GitHub or GitLab. By convention the main one is called origin.

git clone https://github.com/user/project.git    # copy a remote repo locally
git remote -v                                    # show remotes
git push origin main                             # upload your commits
git pull                                         # download and merge new commits
git fetch                                        # download without merging

Authentication

Use an SSH key or a token instead of your password. Add your public key to your GitHub account and clone with the git@github.com:user/project.git form.

The pull request workflow

  1. Create a branch for your change.
  2. Commit and git push -u origin your-branch.
  3. Open a pull request on the hosting site so others can review it.
  4. Address comments, then merge.
  5. Delete the branch and git pull on main.

Notegit pull is git fetch plus a merge. If you want to inspect changes first, run git fetch and then git log origin/main.

CarefulAvoid git push --force on shared branches: it rewrites history others already have.

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

Hintgit push, remote, branch.
HintOne word after git.
3. What is a pull request?
4. Why avoid git push --force on a shared branch?

Key terms