Git Lesson 3: Creating Your First Commit

Abdülbaki Yaşat
2 min readOct 18, 2023

--

Git has become an indispensable part of modern software development processes. In this article, you will learn the step-by-step first steps to start using Git. Whether you’re a new software developer or looking to strengthen your existing skills, this guide will help you take your first steps into the world of Git.

1. Initializing a Git Project

First, create a directory named “GitCourse” and navigate into it to start working with Git:

$ mkdir GitCourse
$ cd GitCourse

After creating the project directory, initialize Git:

$ git init

2. Creating Files

Now, we’ll create two files to work with in this project. You can use the following commands to create a text file named “firstnote.txt” and a Python file named “example.py”:

$ touch firstnote.txt
$ touch example.py

3. Tracking Changes

Once you’ve created the files, you need to inform Git to track these files. You can check the status of your files using the git status command. When you run it for the first time, the files will appear as "untracked files."

$ git status

4. Adding a File to the Staging Area

After starting to track the files, you need to add the changes to the “staging area.” To add the “firstnote.txt” file to the staging area, use the following command:

$ git add firstnote.txt

5. Committing Changes

After adding the files to the staging area, you can save these changes as a “commit.” Each commit represents the state of the project at a specific point in time. You can create a commit with the following command:

$ git commit -m "First commit: Added firstnote.txt file."

Now, the changes have been successfully saved in the current version of the project.

6. Editing the Git Commit Message in Vim Editor

If the Vim text editor opens when you write a commit message, and you enter text input mode, you can follow these steps:

  • First, press “i” to enter text input mode.
  • Write the message you want to edit.
  • When you’re done with editing, press “Esc.”
  • Type :wq to save and exit or simply type :q to exit without saving.

That’s it! You’ve successfully created your first commit.

This beginner’s guide is an excellent starting point for anyone looking to learn the basics of Git. As you progress, you can further enhance your Git skills and make your software development processes more efficient. We hope this article helps you. Happy coding!

--

--