Everything About Git Part: 3

New Git Repository Setup:

Basically, the directory is called Repoitory or ‘Repo’ for short. Now if you want to start Git on any of your projects, first you have to go to the project directory from your Git Bash or your CMD command line. Or if you right click inside your project, you will see an option called Git Bash Here. This will open the git bash with the path of this directory by clicking from inside your desired project directory and you can now type any git command for the directory.

Now suppose you have a directory called git-learn in C: xampp htdocs. And there are some files inside. Now here if you want to start Git. Then you have to type the following command.

git init

Now since we want to track everything inside the git-learn directory, so I run the git init command from inside the git-learn directory. And that’s where Git’s repo setup became inside this directory. Now Git can start tracking all of your repo or directories, all the files or folders inside this directory. However, even if tracked, Git will not store them as versions. For that you have to specifically tell which one exactly when and how to save.

Save a specific file of repository or all files as git version:

Before saving a specific file or repository of repository as git version you first need to understand how git works?

When we make changes to the local repository while working on Git, we are in the working directory. And then after giving the git add command, it goes to the staging area and after giving the git commit command, it is permanently added to the local repository. If you want later, it can be uploaded to the remote (GitHub, gitLab, bitbucket) repository with git push command. Notice the image below:

Check the current status of the git

We now want to see the current status of our Git, i.e. which files are not tracked or which files are in staging. That is why we will use the following command:

git status

Notice that I have two files in this directory named test.php and index.php. Since I just initiated Git in this project, both files are un-tracked here. And also gives some hints on how to track the files.

Taking File Staging Area

Suppose we first want to track our test.php file, that is, we want to take the test.php file to the staging area. That is why we have to give the following command:

git add test.php

The track.php that I have tracked shows it in the Changes to be committed section. And below is the previous un-tracked file. However, at the moment we have the test.php file in the staging area, so if you commit now, Git will only keep this file in the version history. And index.php file that has not been tracked will not do anything about it. Now if we want to give a command to track all the un-tracked files inside this directory then the git command will be as follows:

git add --all


git add .

Now if you give the git status command, you will see that all the tracks are done, which means they are all in the staging area. No files un-tracked. The previous test.php is still in the staging, since we haven’t committed it yet. Now with index.php file and moving to staging area. If you commit now, Git will keep a complete version of the two together.


commit means final. That means you will make the final decision whether to keep your tracked changes in Git Repo? If you think Git Repo will do, you have to commit. And if you want to commit, you have to give a message with each commit so that you can understand at any time later on which committee was done for what reason. Everything will be in one line like this:

git commit -m "New Message Added"

Here New Message Added is the message of our committee.

Note: You cannot commit any file or directory before taking it to the staging area.

Modify the file and re-committed

Now we have a version. But we have a lot more work to do on the project. Now I will add some new variables to the test.php file. The file is currently in the same condition as the new variable and its values

echo "Hello This is my First Git Learn";

Now if you save the test.php file and check the git status, you will see that the file shows it in a modified and un-tracked state.

Now I want to take this un-track file on stage and make a final comment

git add --all

And for the Final Commit:

git commit -m "New Variable $students Added"

Everything About Git Part: 2

Git Installation and Configuration on Computer

In order to start working with Git, you need to make your computer suitable for using Git. That’s why you need to install Git on your computer. Let’s take a look at how to install and configure Git on different OS.


1. Click here to download the Git package.
2. Click on the downloaded file to install it.

Mac OS X:

1. Click here to download the Git package for Mac OS X.
2. Click on the downloaded file to install it.


There are different ways to install Git for different Linux distros. But very simple. Enter the following commands in the terminal according to the distro.

  • Debian/Ubuntu
    # apt-get install git
  • Fedora
    # yum install git
  • Gentoo
    # emerge --ask --verbose dev-vcs/git
  • Arch Linux
    # pacman -S git
  • FreeBSD
    $ cd /usr/ports/devel/git
    $make install
  • Solaris 11 Express
    $ pkg install developer/versioning/git
  • OpenBSD
    $ pkg_add git

Git Configure

I assume you have Git installed on any of the above OS. Now you need to configure Git. And the main purpose of this configuration is that when you commit through Git, he will store your information with Comit. All you have to do is enter your username and email address during the configuration. After Windows users install Git, a shortcut file named gitBash will be created on the computer desktop. You can open it and write the following commands in it. Or you can run the commands directly on the CMD if you want. Linux and Mac OSX users can type commands in the terminal.

git config --global user.name "Your Name Here"

Enter your name in place of Your Name Here.

git config --global user.email "[email protected]"

Enter your Email Address in place of [email protected].

Make sure that the email address you enter here matches the email address of your server account. Now your computer is ready to use Git. From now on you can use Git commands on your computer. We will write all our commands in gitBash, CMD or terminal.

Configure different git for different projects

Suppose you want to have multiple names and emails for multiple projects. That means you have an office project on your PC and you have a personal project. The office project is kept in your office’s GitHub account. You access that account with your office email. Again your personal GitHub account was opened with your personal email. If your project has a global username and email set, but all projects will show the same name and the same email. That’s why you can no longer use global usernames and emails. Now you need to cut out the global keyword and its previous hyphen. And the commands will be as follows:

//Git is configured using an email for the first project
git config user.name "Tortoiz Themes"
git config user.email "[email protected]"
//The second project has been configured with another e-mail
git config user.name "Tortoiz Themes"
git config user.email "[email protected]"

Everything About Git Part: 1

What is Git?

Git is a Source Code Version Control and Source Code Management System, which is a standard system for storing version or revision control of what you have written on your computer before and where you have changed it later. Linus Torvalds designed and developed the Git for the Linux kernel in 2005. Like Linux under GNU General Public License, Git is also an open-source and by far the most popular version control system for software development.

Why use Git?

Since Git is a Version Control Software, it can be easily controlled through any version of Git. Through Git, different developers can participate in the development of the same software, make changes, and a specific developer can finalize those changes. Since Git is a distributed version of the control system, it can also be used as a server. A dedicated Git Server software adds access control to a variety of features, including displaying Git repository content across the web and managing more than one repository. A big advantage of Git is that many developers can work on a project at the same time. You can work without an internet connection if you want. Although Git was initially developed for Linux, it also supports other operating systems, such as BSD, Solaris, OS X, and Microsoft’s Windows.

Before you start working on Git, you need to know about the most commonly used commands:

  • git init – Used to create a new repository.
  • git config – used to set configurations in git.
  • git status- Check the current status of git.
  • git add – Used to add one or all files together in a repository.
  • git clone – Used to download complete information from a pre-existing repository.
  • git commit – Used to permanently attach work to an offline repository.
  • git pull – Used to download files from a remote repository and merge with an offline repository.
  • git log – Used to check the log of git.
  • git push – Used to upload files from offline repository to remote repository.
  • git branch – used to create new branches in the repository.
  • git checkout – Used to switch from master branch to another branch.
  • git merge – Used to merge one branch with another.