Home / Git

Basic Git commands: init, add, commit, status, log

Git is a distributed version control system that allows multiple developers to work on a project simultaneously and track changes made to the codebase. In this article, we will explore some basic Git commands that every developer should know: init, add, commit, status, and log.

1. git init

The git init command initializes a new Git repository for your project. It creates a hidden folder called .git that contains all the necessary files and subdirectories to manage your project's version control.

To initialize a new Git repository, open your command-line interface (CLI) and navigate to your project's directory. Then, run the following command:

$ git init

2. git add

After initializing a Git repository, the next step is to add files to the staging area before committing them. The git add command allows you to stage changes for commit. You can either specify individual files or use wildcards to add multiple files simultaneously.

To add a single file to the staging area, use the following command:

$ git add <file>

To add all the files in your project directory, use the following command:

$ git add .

3. git commit

Once you have added the necessary changes to the staging area, you are ready to commit them. A commit is a snapshot of your project at a specific point in time, and it represents a coherent set of changes.

To commit your changes, use the following command:

$ git commit -m "commit message"

Make sure to write a meaningful commit message that describes the changes you made. It helps you and your collaborators understand the purpose of the commit.

4. git status

The git status command shows the current state of your Git repository. It displays information about files that are tracked or untracked, files that are staged or unstaged, and any changes that need to be committed.

To check the status of your repository, use the following command:

$ git status

This command provides valuable insights into the current state of your project and helps you keep track of your changes.

5. git log

The git log command allows you to view the commit history of your repository. It displays a list of commits in reverse chronological order, showing the commit hash, author, date, and commit message.

To view the commit log, use the following command:

$ git log

The commit history helps you understand the evolution of your project and provides a timeline of all the changes made so far.


These are some of the basic Git commands that form the foundation of version control with Git. By understanding and utilizing these commands effectively, you can keep track of changes, collaborate with other developers, and maintain a well-documented commit history.

Remember, Git offers numerous other commands and features that can elevate your development workflow. So keep exploring and learning to unlock the full potential of Git!


noob to master © copyleft