← All topics

GIT & VERSION CONTROL · REFERENCE

Storage, Hosting, and Remotes

Keep history locally, choose an online host, or use your own server. The core Git operations stay the same.

At a glance

Term or command What it means When to use it
Local repository History stored on your own computer. Use Git offline; no hosting account is required.
Remote repository Another repository addressed by a URL or filesystem path. Exchange commits with another location.
origin A conventional nickname for a remote. Clone normally creates it; the name is not tied to one provider.
git remote -v Lists configured remote URLs. Check where fetches and pushes will go.
git fetch origin Downloads remote objects and updates remote-tracking references. Inspect remote progress without merging into your current branch.
git pull --ff-only Fetches and advances your branch only when a fast-forward is possible. Update a tracking branch without silently creating a merge commit.
git push -u origin main Pushes main and configures its upstream. Share the branch once permissions and the remote exist.

Commands are examples, not an interactive terminal. Run them in your own learning repository after checking the prerequisites. Output, paths, commit IDs, and wording can vary. Host-specific instructions are labeled.

Where can a Git repository live?

Location What it provides How to think about it
Your computer A working project and its local history. Best starting point for learning; use backups because one disk is a single location.
GitHub A Git host with pull requests and automation. Used for this guide’s worked online examples; it is optional.
GitLab Hosted or self-managed Git repositories with merge requests and CI/CD. An alternative for sharing and managing Git projects.
Bitbucket Git hosting in Atlassian’s collaboration tools. An option for teams using the Atlassian ecosystem.
Azure Repos Git repositories within Azure DevOps. An option within Microsoft’s development tools.
Codeberg A community-oriented Git collaboration service. Check its project and usage policies when choosing a home.
Your server A server running a Git hosting platform or serving bare Git repositories. You control access, updates, and backups.
Another folder or drive A remote can be a filesystem path rather than a website. Useful for demonstrations or a separately managed copy; same-disk copies are not independent backups.

Choose a host for your needs

Consider who needs access, whether the project is public or private, collaboration features, storage limits, authentication, and backup/export needs. Read current provider policies rather than assuming every host offers the same free plan. Moving normal Git history between hosts is possible, but issues, reviews, permissions, and automation often need separate migration.

GitHub example: connect a local repository

In GitHub, create an empty repository named my-website. For this route, do not initialize it with a README or license: your local repository already has its own commits. Copy its HTTPS clone URL. Replace YOUR-NAME in the command before running it inside your existing local project.

git remote add origin https://github.com/YOUR-NAME/my-website.git
git remote -v
git push -u origin main

This assumes your branch is main and you have authenticated with permission to push. GitHub is only the example host. For GitLab, Bitbucket, Codeberg, or Azure Repos, copy that host’s clone URL instead; do not just guess the URL format.

What fetch and pull do

Prerequisite: your main branch tracks origin/main, your working tree is clean, and someone has added a compatible commit remotely.

Commands

git fetch origin
git log --oneline main..origin/main
git pull --ff-only

Example output

c3d4e5f Add route description

Updating b2c3d4e..c3d4e5f
Fast-forward

Fetch updates your view of remote history without updating the current checked-out branch. Pull then attempts integration. If --ff-only refuses because histories diverged, stop and review the branches; the refusal does not mean your work disappeared.

One project can have more than one remote

git remote add backup https://git.example.org/your-name/my-website.git
git remote -v

The URL is a placeholder for a repository you have actually created. Adding a remote only records an address. It does not create that repository or send commits. Each remote needs its own permissions, and you choose which one to push to.

Sources and further reading

Study questions

Explain it in your own words, then open the answer.

Is origin another name for GitHub?

No. It is a conventional remote nickname that can point to many different hosts or locations.

Does git remote add upload history?

No. It records the address. Push sends commits.

How does fetch differ from pull?

Fetch updates remote-tracking information; pull fetches and integrates into the current branch.

Can I use Git without an online host?

Yes. Local commits and history work without one.

Does switching hosts automatically move issues and reviews?

No. Git history and hosting-platform metadata are different things.