How a shared Git remote links your copy and a friend's: cloning, committing, pushing, pulling and merging changes between them.
Git keeps a project's whole history as a chain of saved snapshots called commits. In the middle sits the remote: a shared copy on a server that everyone can reach. You and a friend each work on your own copy at your own desk.
Git was started by Linus Torvalds in April 2005. GitHub is just one place to host a remote.
To join in, you clone the remote. Git copies every commit and the full history to your desk, and remembers the remote under the nickname origin. It is a real copy, not a link, so you can work offline.
You change some files, then commit. The new commit joins the end of your chain, linked to the one before it. Nothing is sent anywhere yet: commits live only on your own copy.
Push uploads the commits the remote does not have yet. Now the shared copy holds your snapshot too. Pushing needs permission to write to that remote.
Your friend pulls your commit down, adds a commit of their own and pushes it. The remote moves ahead, but your copy does not change by itself. Git never updates your desk until you ask.
You make another commit and try to push. The remote refuses, because it holds a commit you have never seen. Git will not let you quietly overwrite your friend's work.
Git calls this a rejected push. The fix is always the same: get their work first.
Pull is two moves in one. Fetch downloads the new commit, then merge weaves both lines of work together with a merge commit that has two parents. Your copy now contains everyone's work.
Fetch alone is always safe: it downloads but never touches your files.
On many teams you push to a separate branch and open a pull request: a page asking others to review your work. Your friend checks it and approves, then it is merged into main on the remote.
Your friend pulls, and now all three copies hold the same history. Clone once, then commit, pull and push again and again. That loop lets many people build one project together.
A remote does not have to be on the internet: it can be another computer, or even another folder.