Cloning and Tagging

INPUT · Slides

Clone repositories and manage release tags (clone / remote / tag)

01 / 08

Starting development in teams (Repository Cloning)

In previous chapters, we mostly initialized new repositories with git init.

In actual engineering teams, however, running git init from scratch is relatively rare. Typically, you clone an existing project from GitHub to your local machine to begin development.

In this chapter, you will master three core commands:

  • git clone … Duplicate an entire remote repository (all commits, branches, and files) locally
  • git remote add … Link a local repository to a remote repository URL
  • git tag … Assign a fixed version label (such as v1.0) to a specific commit

02 / 08

git clone — Duplicate an entire repository locally

Running git clone <repository-url> downloads the entire commit history, all branches, and all files to your machine.

Rather than just fetching the latest file contents, the full history of past commits is cloned. This means git log and git diff work immediately after cloning.

Furthermore, the source URL is automatically configured under the remote alias origin, allowing you to run git push and git pull right away.

$ git clone https://example.com/team/project.gitCloning into 'project'...remote: Enumerating objects: 3, done.Receiving objects: 100% (3/3), done.

03 / 08

Differences between clone and init

The only practical difference between the two commands is whether commit history and remote settings already exist at the start.

  • git init … Initializes a blank repository from scratch (zero commits, no remotes)
  • git clone … Duplicates an existing repository from a remote (full history included, origin configured)

Once setup is complete, all subsequent development workflows (add, commit, push, pull, branch) are completely identical.

04 / 08

Registering a remote repository (git remote add)

When you create a new repository using git init, no remote destination is configured by default. Attempting to run git push will fail with an error.

Use git remote add <name> <url> to register a remote repository destination:

git remote add origin https://example.com/you/mine.git

Once registered, you can reference the remote destination using the shorthand alias origin instead of typing the full URL.

$ git pushfatal: 'origin' does not appear to be a git repository

05 / 08

What is origin? (Conventional remote alias)

The name origin seen in previous chapters is not a reserved Git keyword.

It is simply the default alias assigned to the source remote repository by git clone. Just as the default branch is conventionally named main, the primary remote repository is universally called origin by convention.

You can inspect currently configured remote repositories and their URLs with git remote -v.

$ git remote -vorigin	https://example.com/you/mine.git (fetch)origin	https://example.com/you/mine.git (push)

06 / 08

git tag — Fixed version labels on commits

git tag assigns a permanent version label (release tag) to a specific commit.

git tag v1.0

Without additional arguments, the tag is attached to the current HEAD commit. To tag a historical commit, specify a commit reference like git tag v1.0 HEAD~2 or a commit hash.

Tags are typically created for production milestones (e.g., v1.0.0) so that releases can be referenced reliably in the future.

$ git tag v1.0$ git log --oneline9f2a1c4 (HEAD -> main, tag: v1.0) the first release3b7e5d1 built the base

07 / 08

Branches vs Tags (Moving pointers vs fixed labels)

While both branches and tags point to commits, they serve fundamentally different purposes:

  • Branch (Moving pointer) … Automatically advances forward whenever a new commit is created
  • Tag (Fixed label) … Permanently stays attached to the exact commit where it was created

Because tags never move, you can reliably restore or inspect an exact release state at any time using git reset --hard v1.0 or git switch v1.0.

08 / 08

Summary of the Git workflow

With these tools, you now understand the full lifecycle of standard Git commands:

  • Record … init / add / commit
  • Branch & Merge … branch / switch / merge
  • Collaborate … push / fetch / pull
  • Propose changes … Pull Requests (PRs) & code reviews
  • Undo & Reset … restore / reset / revert / commit --amend
  • Shelve & Ignore … stash / .gitignore
  • Inspect history … log / show / diff / blame
  • Setup & Release … clone / remote / tag

The foundation of Git lies in its three areas: the working tree, the staging area (index), and the repository. When in doubt, check git status to locate your changes.