Beginner lesson 5 of 6

Understand Git remotes: clone, fetch, pull, and push

Practice sharing commits with a local bare remote and two clones, without credentials or a hosting account.

Before you start

A remote is a named repository destination, not necessarily a website. This exercise creates a bare repository (history without editable working files), then two local clones named alice and bob. A remote-tracking ref such as origin/main records what your latest fetch saw; it is not a live connection.

Use Git 2.28 or newer in a POSIX shell on macOS/Linux, or Git Bash on Windows. Check git --version; Git's installation page covers setup. Each example starts in a new temporary folder. Keep that folder if you want to revisit your work; none of these commands removes your existing projects. The identity and signing settings below apply only to the practice repository.

Work through the example

practice=$(mktemp -d "${TMPDIR:-/tmp}/gitglow-learn.XXXXXX")
sandbox="$practice/project"
mkdir "$sandbox"
cd "$sandbox"
git init -b main
git config --local user.name "Git Learner"
git config --local user.email "learner@example.invalid"
git config --local commit.gpgsign false
git init --bare -b main origin.git
git clone origin.git alice
cd alice
git config --local user.name "Git Learner"
git config --local user.email "learner@example.invalid"
git config --local commit.gpgsign false
printf 'A small project\n' > notes.txt
git add notes.txt
git commit -m "Start notes"
git push -u origin main
cd ..
git clone origin.git bob
cd bob
git config --local user.name "Second Learner"
git config --local user.email "second@example.invalid"
git config --local commit.gpgsign false

Make a change in bob and publish it to the local remote:

printf 'A note from Bob\n' >> notes.txt
git add notes.txt
git commit -m "Add Bob note"
git push
cd ../alice
git fetch origin
git log --oneline main..origin/main
cat notes.txt
git pull --ff-only
cat notes.txt
git remote -v

Check the result

Fetch updates origin/main but leaves alice’s working file unchanged. Pull with --ff-only then moves alice’s branch forward and the file includes Bob’s line. Push transfers commits from bob to origin. Cloning the initially empty bare repository may print an expected empty-repository warning.

Try it yourself

Commit a new line in alice and push it. In bob, fetch and inspect the incoming commit before pulling. If either clone has unrelated edits, pause and inspect them first.

If something goes wrong

If --ff-only refuses a pull, local and remote histories diverged; inspect the graph and decide how to reconcile them. It is intentionally refusing an automatic merge or rebase. Authentication on real hosted remotes is separate from commit identity; none is needed for these local paths.

Use this workflow in GitGlow

Open alice or bob in GitGlow and inspect the remote and active branch. Fetch, Pull, and Push are Free desktop actions; inspect the preview before confirming. GitHub integration is optional and separate from Git remote access.

Download GitGlow Free

Go deeper with the official Git docs

These references cover command options and behavior beyond this example.