Skip to content

Chapter 2 of 7

Essential Daily Commands

Starting a new project or joining an existing one both rely on a small set of foundational Git commands. The command git init initializes a brand-new repository in the current directory by creating the hidden .git folder that holds all version-control data. To obtain a copy of an existing remote repository, developers use git clone <url>, which downloads every branch, tag, and historical commit into a new local working directory.

Once a repository exists, changes move through Git's three areas in a deliberate workflow. The command git add <file> stages modifications from the working directory into the index; git add . stages every change in the current directory at once. After staging, git commit -m "message" records those changes as a permanent snapshot in the local repository. The accompanying commit message should concisely describe the purpose of the change, helping teammates understand the project's evolution.

Two commands help developers stay oriented throughout this workflow. Running git status displays the current state of the working directory and the staging area, listing which files are modified, untracked, or ready to be committed. To review what has already been committed, git log prints the commit history, showing hashes, authors, dates, and messages. Options such as --oneline or --graph produce compact or visually structured views, which are especially useful in projects with many branches.

All chapters
  1. 1Introduction to Git and Its Core Concepts
  2. 2Essential Daily Commands
  3. 3Branching, Merging, and History Shaping
  4. 4Collaborating with Remote Repositories
  5. 5Undoing, Reverting, and Recovering
  6. 6Tags, Submodules, and Productivity Tools
  7. 7Customizing and Maintaining Your Repository

Drill it

Reading is not remembering. These come from the Git Version Control deck:

Q

What is Git?

Git is a distributed version control system that tracks changes in source code during software development, allowing multiple developers to collaborate efficien...

Q

How do you initialize a new Git repository?

Use the command git init in the root directory of your project.This creates a hidden .git subdirectory containing all repository data.

Q

What does <code>git clone</code> do?

git clone &lt;url&gt; creates a copy of an existing remote repository on your local machine.It includes all branches, tags, and history.

Q

What is the purpose of <code>git add</code>?

git add &lt;file&gt; stages changes in the working directory for the next commit.You can stage all changes with git add . or specific files.