Getting Started with Version Control: A Beginner’s Guide

Mukesh Awasthi
3 min readFeb 4, 2024

--

Introduction:

VCS or Version Control System is a tool that manages different versions of source code. It is a software that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to work together with other programmers.

Git:

Git is one of the most popular distributed VCS. It is a distributed open source version control system commonly used to track and manage changes in the source code. It also lookout for changes in the files including who made the changes.

Git helps us to:
1. Track Document versions.
2. Keep the history of document changes.
3. Encourage teamwork.

GitHub:

While Git keeps track of the changes in the code, GitHub is a cloud service that help teams in communication, collaboration and project management. It consist of repositories that can be private or public for source code storage. Only the owner and collaborators can view or contribute to a private repositories while public repositories are visible to everyone.

We should be careful of what we publish on our public repositories.

Git Terminologies:

Commit:
Git thinks of its data like a set of snapshots of a mini file system. Every time we commit or save the state of our project in Git, it basically takes the picture of what our files look like at the moment and stores a reference to that snapshot. We can think of it as a save point in a game. Everything we do in Git is to help us make commits. So, commit is the fundamental unit of Git.

Repository:
A repository is a directory which contains our project as well as other few files which are used to communicate with Git. Repository can exist either locally on our PC or as a remote copy of another computer. A repository is made up of commits.

Working Directory:
Working directory is the files that we see in our computers file system. When we open our project files up on a code editor, we are working with the files in the Working Directory. This is in contrast to the files that have been committed in the repository.

Basic Git Commands:

  1. git init
    Command:
    git init
    Used to initialize empty git repository locally.
  2. git status
    Command:
    git status
    Displays the state of working directory and the staging area.
    Lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.
  3. git add
    Command:
    git add file_name or git add .
    The “.” in the command is used to add multiple files at same time.
    Used to add the edited file from working directory to staged area.
  4. git commit
    Command:
    git commit -m "commit message"
    Used to create the snapshot of staged changes for git repository.
  5. git push:
    Command:
    git push file_name
    Used to push the code changes made in local repository to remote repository.
  6. git log:
    Command:
    git log
    Used to view the logs of commit in the repository.
  7. git checkout:
    Command:
    git checkout branch_name
    Used to switch from one branch to another branch.
  8. git branch:
    Command:
    git branch new_branch_name
    Used to create new branch.

Git Command Workflow:

The commonly used git command works in the following manner.

--

--