What problem does version control solve?

When a file changes repeatedly, copies named “final-report-2” do not explain what changed or how to recover an earlier state. A version control system records changes so you can review revisions, compare them, and restore specific versions.

Although version control is most closely associated with software development, it can also be used for documents, designs, and other files. A project’s history helps show how it has evolved and reduces reliance on manual copies that can be confused with one another.

In a team, each person can work on a task and propose how to integrate their changes. The tool preserves revisions and can help identify incompatibilities, but it cannot decide which change is correct; that judgment depends on people who understand the project and its requirements.

CVS and Git: two different models

CVS is a centralized version control system: collaborators work with a shared repository hosted on a server. Git is distributed, so each clone contains a copy of the repository and its history. Many operations can be performed locally while offline, although sharing changes requires synchronization with another repository.

In Git, a remote repository often serves as a shared point for exchanging work, but it is not necessarily the only place where the history exists. The distributed model gives each collaborator autonomy; in return, the team must agree on when to update and how to integrate contributions.

Moving from CVS to Git involves more than learning new commands: it also changes how revisions, branches, and repositories are managed. This guide covers Git concepts and basic use; it is not a migration procedure and does not guarantee that a conversion will preserve history. The right strategy depends on the repository and the project’s needs.

The basic Git cycle

Git distinguishes three areas. The working directory contains the files being edited; the staging area, also called the index, holds the changes selected for the next commit; and the local repository stores committed history. Staging separately from committing lets you choose which changes to group together.

A commit records a snapshot of the project along with metadata. Changes that have not been staged and committed are not part of the history. git status shows the state of files, while git diff lets you inspect differences; reviewing them before committing helps prevent accidental inclusions.

Branches let you work on separate lines of development and then integrate changes, for example, with a merge. If Git cannot combine incompatible changes automatically, it reports a conflict for a person to resolve. The program compares changes, but it does not know the team’s intent.

Git’s basic change cycle

A text alternative to the workflow: edit files, select changes for the next commit, review that selection, then record it in the repository history.

  1. 1. Edit

    Make changes in the working directory

  2. 2. Stage

    Choose what to include next

  3. 3. Review

    Check the staged changes

  4. 4. Commit

    Save the changes in project history

Basic local Git workflow

This summarizes a basic cycle; collaboration and remote synchronization are separate activities.

Sources and references2

Create a repository and record changes

Install Git by following the instructions for your operating system. You can configure the name and email address associated with your commits. The --global option applies those values to your repositories on that machine; you can also set project-specific values.

To start a project, initialize a repository in its folder. If the project is already on a server, you can usually get a copy with git clone. In this example, replace the identity details and folder name with your own:

git config --global user.name "Your name"
git config --global user.email "your-email@example.com"
mkdir project
cd project
git init
git status

Before committing, check the status and stage only the files you want to include. Then inspect the staged changes and create a commit with a message explaining its purpose. Reviewing before you commit helps catch forgotten files or changes that do not belong in that unit of work.

git status
git add README.md
git diff --staged
git commit -m "Add initial instructions"
git log --oneline

git add selects changes for the next commit; git diff --staged shows what is selected, and git commit records it in the history. git log --oneline displays a concise summary of commits.

A shared workflow

To collaborate, the team should agree on which remote repository to use, which branch will serve as the integration branch, and how changes will be reviewed. Git supports different workflows; one option is to use short-lived branches for individual tasks and review contributions before integrating them. The key is to agree on clear rules about who integrates changes and when a contribution is ready.

To work on a remote project, use git clone to create a local copy. Once changes are staged and committed, git push can send them to the remote repository. Reviewing changes through a pull request is a feature of hosting platforms, not a Git command.

git fetch retrieves information from the remote without automatically integrating changes into the current branch. git pull fetches changes and starts integrating them according to the repository’s configuration. Before using it, understand which branch will be updated and how the changes will be integrated: although both commands exchange information with a remote, they do not have the same effect on the active branch.

A simple starting routine is to create a branch for each task, make focused changes, review the status and differences, create one or more commits, and share the branch for review. The team can adapt the sequence and tools to its needs; Git does not impose a single process or replace technical review.

Conflicts, recovery, and precautions

A conflict occurs when Git cannot integrate certain changes automatically, such as incompatible edits to the same part of a file. To resolve it, compare the versions, choose the intended result, and check it before completing the integration.

The right command for correcting history depends on the situation. git revert creates a new commit that reverses the effects of another while preserving the existing history. By contrast, git reset --hard discards uncommitted changes from the staging area and working directory; it can delete work that has not been committed. Check the status before running it.

Having a remote clone does not, by itself, provide a complete backup strategy. You should also avoid uploading credentials and private files: information can remain in the history even after it is removed from the current version.

Useful checks and next steps

Before committing, review which files changed, what you staged, and whether the commit message explains the change’s purpose. Before sharing a branch, check the remote destination and make sure it contains no secrets or private data. Shared conventions for branch names, reviews, and conflict resolution make collaboration easier.

These commands cover a basic routine:

  • git status: check the state of the working directory and staging area.
  • git diff and git diff --staged: review unstaged and staged changes.
  • git add <file>: select changes for the next commit.
  • git commit -m "message": record a unit of work.
  • git log --oneline: view a concise summary of the history.
  • git fetch: retrieve data from the remote without integrating it into the active branch.

Practice in a test repository using disposable files: create a commit, create a branch, edit the same file on two branches, and resolve the conflict. Pro Git covers the fundamentals, branches, and remote repositories; Software Carpentry offers an introductory Git lesson in Spanish.