What is Git?
Hello guys. This is my first article and I want to talk about Git. Git is the most populer version control system that enables you store and manage your “codes” as versions (commits). And also you can track, compare and revert changes. These gives you a big power over your project to be able to manage it.
I stated the word “codes”, because it has been especially developed for developers .
How to install?
If you want to use Git, first you visit the following url, download and install the relevant version for your operating system.
Git
Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion…
git-scm.com
If you can properly install the Git you can use git commands in terminal. At first, type the following Git command and press enter in your terminal:
git --version
If the message is something like above, this means you succeeded the installation:
git version 2.34.0.windows.1
But if the message is something like above, this means you failed:
‘git’ is not recognized as an internal or external command,
If you get this type of error in Windows operating system and also sure to installed it, I recomended that you should check “environment variables” in Windows control panel. Please be sure that existing of “Git\cmd” folder in Path variable on system variables
Setting up Git
Before going on, you should setup some configurations. These settings are absolutely not about git or github credentials. They are all about defining the owner of commits.
git config --global user.name "Mona Lisa"
git config --global user.email "[email protected]"
How to create a repository (project)?
In Git, “repository” means space which you can create your project and enable version control mechanism in it.
To create a Git repository you should type the following command in your project folder.
git init
The Git repository is initialized after the above command. You can see “.git” folder if you enable “Show hidden files, folders, and drives” option in advanced settings of folder from Windows explorer settings. This folder is very important, since Git stores all version changes and settings in it. If you delete it you will loose your version history.
How to create version?
If you want to create version, firstly you have to create some content in the project folder where you enabled the Git repository. Because Git does not consider the empty folders and Git traces the changes. If there is no changes you can not create commit. Always the version should have some changes differs from the previous one.
Before creating commit, you should know several concepts about Git: Working space, staging area, commit store.
Working Space: It is your project folder which includes .git folder and project files.
Staging Area: It is a waiting room that collects the changes to be committed. A commit (version) is created from the files which resides in Staging Area.
Commit Store: It is a store contains all versions of the project(repo)
Now we are ready to create commit
First you can use the following command to send all changes to the staging area:
git add .
And then you can use the following command to create commit from staging area.
git commit -m “first commit”
Congratulations! You have just created a version (commit). Anymore you can create new commits by following the steps above.
You may also like

Core Java Programming Language

Core Java Questions Bank for Beginners to Advanced
