
Here's a preview from my zine, How Git Works! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

read the transcript!
any repository you’re pushing to / pulling from is called a “remote”
remotes can be:
- hosted by GitHub/GitLab/etc.
- on your own server
- just a folder on your computer
git push syntax
(same for git pull)
git push origin main
“origin
” is the remote name, “main
” is the remote branch.
the default name for a remote is origin but you can name it anything
tip!
I like to configure push.autoSetupRemote true
to automatically set up tracking the first time I push a new branch
remotes are where the drama happens
Smiling stick figure with short curly hair: I spent 3 hours working on cats.py
person: git pull
git, represented by a box with a smiley face: fun fact! your coworker totally rewrote that file!
example: I use 2 remotes when contributing to open source projects
Diagram of a box labelled “local repo”. Local repo has an arrow labelled “push to here”, pointing to a box labelled “My personal GitHub fork”. That box has an arrow labelled “pull request”, pointing to a box labelled “main project repo name: “origin””. That box has an arrow labelled “pull from here”, pointing back to the “local repo” box.
remotes are configured in .git/config
every remote has a name and URL
[remote "origin"]
url = git@github.com:jvns/myrepo
branch ["main"]
remote = origin
merge = refs/heads/main
“origin
” is the name, “git@github.com:jvns/myrepo
” is the URL.
this sets up “tracking” between local main remote main on origin so that git knows what to push to when you run git push or git pull
protocols
Git has 3 main protocols for remotes. The protocol is embedded in the URL.
- HTTP (I use this if I only want to pull)
https://github.com/jvns/myrepo
- SSH (I use this if I need to push)
git@github.com:jvns/myrepo
- local
file:///home/bork/myrepo
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!