What is 'git' and how to get started?
git basics | installation | getting started | commands

A student of CSE, having interest in open source and development...
What is git?
gitis a free and open source distributedVCS(version-control-system).- Today almost all projects whether it is small hobby project or big commercial project, developers use
gitfor version control.
but wait, what is VCS?
- What is VCS? do give it a minute...
so, now we have an idea what is VCS...
Let's get into git:
Installation
For windows
go to https://git-scm.com/download/win and download the client according to the windows configuration.
Fo Linux [Debian]
apt-get install gitFor macOS
brew install git
Getting started
- Let us have a directory
git_tuto, we will play with this directory only.
to begin withgit_tutois empty.

- Now we have to configure
git, set user-name and user-email. This user-email is typically the same as the email linked with GitHub (An internet hosting service for software development and version control usinggit), but for the sake of this tutorial, we will temporarily set a dummy email.
go to git_tuto directory and open terminal or git-bash
setting name as 'san'git config --global user.name "san"
setting email as 'san@mail.com'git config --global user.email "san@mail.com"
if we do,git config --global --list

- Let us start with the command
git status. You will be using this command almost at every time,git statusshows the current status of the directory.
git status

what happened?
We have to first make the current directory a git maintainable directory.
We have to initialize the git.git init

now if we do:git status

We have initialized git in git_tuto directory, now from onwards, we will call this directory a repository or simply a repo (a git initialized directory is typically called repository).The above message tells that there is nothing that has changed, the default branch (a particular stream in a repo) is master, in some cases it may be main also.
Let's play
- let us create two files
fname.txtandlname.txtingit_tutorepo.
fname.txt contains
Elon
lname.txt contains
Musk
if we do,
git status
gitis telling that both the filesfname.txtandlname.txtare untracked files, which meansgitis not maintaining or counting the changes happening in these files.
* All the untracked files will be displayed in 'red' color.
We have to explicitly tellgitto track these files.
For that, we have a commandgit add <file-name>
* If we wantgitto track all files in the current repo, then we have to dogit add ., here ' . ' means all files.Let's do
git add .
nowgitis tracking changes in these filesgit status

After doing git add ., all the files will come into the staging area (which means we have accepted the changes, now we just have to commit (finalize) them.
* All the files which are in the staging area will be displayed in 'green' color.
- To commit or finalize the changes we just have to enter
git commit -m "<commit-message>"
'-m' flag signifies 'commit-message'.
an empty 'commit-message' will abort this operation.git commit -m "Initial commit"

git status

Up to this point, we are tracking two files, and committed the changes in them, means there is nothing to be worried about. Everything is maintained.
To see the commit history, we have a command git log
git log
This will list down all the commits we have made in the repo, for our case, it will show
We can see the 'commit-message' which we have provided as "Initial commit".
The long string after 'commit' is called 'commit hash', it is uniquely generated bygitfor every commit we make.
Now, let's change fname.txt and recur the above process.
fname.txt will now contain
Jeff
git status

Now observe, git is telling that fname.txt is modified.
Let add it to the staging area and commit.
git add fname.txtgit status

git commit -m "fname.txt changed to Jeff"

git log

We have both our commits along with their commit-hashes and other info.
Similarly we can change, add, commit with no limits.
These are the basic commands to start with git, it has a lot of other functioning and capabilities too, we will see them eventually.
Stay tuned!
Hope you liked it...
