Git: Working with a remote

A remote is a clone of your repository, positioned on another machine.

GitHub is one of the most commonly used remotes.

If you have an existing repository, you can publish it on GitHub.

The procedure involves creating a repository on the platform, through their web interface, then you add that repository as a remote, and you push your code there.

To add the remote type

git remote add origin https://github.com/YOU/REPONAME.git

An alternative approach is creating a blank repo on GitHub and cloning it locally, in which case the remote is automatically added for you

Once you’re done, you can push your code to the remote, using the syntax git push <remote> <branch>, for example:

git push origin main

You specify origin as the remote, because you can technically have more than one remote. That is the name of the one we added previously, and it’s a convention.

The same syntax applies to pulling:

git pull origin main

tells Git to pull the main branch from origin, and merge it in the current local branch.

Lessons in this unit:

0: Introduction
1: Installing Git
2: Initialize a repository
3: Commit changes
4: Branches
5: Push and pull
6: ▶︎ Working with a remote
7: Solving conflicts
8: .gitignore
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. Launching May 21, 2024. Join the waiting list!