Git Mastery: A Comprehensive Guide to Version Control with Git : Part-1

Table of contents

As we have already seen that Git is a version control system that is used to track changes to files, allowing developers to easily collaborate on projects and roll back changes if necessary. In this blog we shall see how to get started with Git?

To get started with Git, you will need to download and install it on your computer. You can download the latest version of Git from the official website at git-scm.com.

Once you have downloaded and installed Git, you will need to configure it with your personal information, like your name and email address. This is a one-time process. This can be done in git bash terminal. To configure:

  1. Create a folder anywhere in the local computer. This is the place you can store all of your source code.

  2. Open the folder, right click -> select show more options (if you are using Windows 11) -> select git bash here.

  3. Git bash will be opened.

    Note: Git Bash is a terminal application for Windows that provides an interface for running Git commands. It is included with the Git for Windows installation, and allows you to use Git from the command line in a Unix-like environment.

  4. Now run the following commands:

     git config --global user.name "Your Name"
     git config --global user.email "your_email@example.com"
    

    Note:

    Using the flag "--global" will set your name and email as the default for all of your Git repositories on your computer.

    To set the username and password for a specific repository, you can navigate to the directory containing the repository and run the same commands, but without the "--global" flag. This will set the username and email only for that repository.

  5. To check whether you have successfully configured or not you can use:

     git config --global --list
    
  6. Done :). You are now all set to experience and enjoy the power of Git.

Using Git

To use git, we have to convert our newly created folder to the "Working directory". A working directory is a folder where the developer saves or stores all the source code. This can be done by using the command:

git init

"init" stands for initialize. After running the init command we get the following message:

Now we have successfully converted our folder into a working directory.

Observations: After we convert our folder to working directory, we get:

  1. Something called as master (beside the address). The term master refers to the main branch of a repository. This branch is usually used to track the production-ready version of your project, and is often considered the "default" branch of the repository.

  2. .git folder is created in our working directory.

    Note: To see the hidden folders go to View (on the top of the window) -> Show and check Hidden Items option.

Thats all for today, In the next blog we will discuss various types of files, sections and how to move files from one section to the other.

Stay tuned!