- · A developer must know about VCS(Version Controlling System).
- · A pro-level developer knows about the front layer of the VCS and behind the scenes of that scenario.
Step 01
- ·
First of all we need to install the software.
(name – git bash)
- · If you already installed it, you can check it on cmd by typing “git version”.
- It will give you the version of your git.
-
If the version is not showing, you have to
download and install the git.
- · Links:-
o
Windows - https://git-scm.com/download/win
o
macOS - https://git-scm.com/download/mac
o Linux - https://git-scm.com/download/linux
History
The
founder of Linux, Linus Torvalds wanted to maintain a day-to-day history.
For that, he created a system called git (git and git-hub are not the same).
The
major use of git is we can manage the history (there are many other options).
There are three options in a VCS.
·
Local
·
Centralized
·
Distributed
Local VCS
- Day by day you make a copy of your progressed
project and move on.
- There are many drawbacks because it is handled locally so there can be more copies and more copies mean more storage. And if something happens to the computer, the whole project is gone.
- Here, there is a centralized machine(server) and
each developer uploads their work to that machine. So the other developers can
take it and do the development.
- The case is we can only access the latest copy(snapshot). Which means the copy that was uploaded last. We can not access the previous versions.
- Another drawback is if the server becomes out of order, anyone can not do their developments.
Distributed
VCS
- · Here developers can access all the snapshots(copies).
- In semantic versioning, we change the patch number after fixing a bug.
- If we add a new feature, the minor number must change.
- · If minor numbers have changed, all the right-side numbers have to be 0.
- If the whole system is changed completely, then the major number changes.
- · All right-side numbers have to be 0.
Major
stages in git
·
Mainly there are 4 stages in git.
·
Modified stage(working directory)
·
Staged area
·
Committed
·
Stash area
·
If we make any modifications, it moves to the
modified stage. However, a copy is not stored yet.
·
If we want to store and update the history then
the file moves to the staged area.
·
When we commit, the file moves to the committed
area and then anyone can access that modified file.
Step 02
·
After installing git bash, create a new folder.
·
Go to that folder, right-click, and select open
git bash here.
Git Configurations
·
We can divide the git configuration into mainly
3 parts.
·
Local
·
Global
·
System level
·
Local configuration files are in repo(project)/.git/config (.git
means, it is a hidden file).
·
Global level files are in users/**unsername**/.gitconfig.
·
System level files are in user/local/etc/.gitconfig
Now let’s work with git bash.
·
In that opened git bash type,
$ git config --list --show-origin
You will get a huge list like this. It shows all the
system-level configurations and also user-level configurations. (note that
if you are a new user you will not see these user-level configurations)
Now let’s move on to version controlling.
·
In that newly created folder make another folder
for our project and in there make a index.html file.
·
Now we have to tell to git bash to manage our
project.
·
For that go inside to your project folder, right
click, and open git bash.
·
There type $ git init. It will create
an empty repository(a small project folder) for you. (make sure to
tick the hidden items in windows).
·
If you type $ ls in git bash, it will
show you the files inside that repository.
·
If you type $
clear you can clear the console.
·
Now our file is in modified state.
·
If you type $ git
config user.email, you can find who is building this project.
·
If you are a new user you have to configure your
git. Otherwise, this will not be shown.
· For that you need to type $ git config --local user.email *your git email*.
·
Similarly you can change the user name as well.
·
Type - $ git config --local user.name *your user
name*
· You can see your all local git configurations
inside .git file.
· You can remove your local git configurations as
well.
· Type - $ git config --local --remove-section user
·
To see the status of our repository - $ git status
·
If you do not remember the codes, you can use $ git help
· If you want to know what happens from a specific
code, you can use $ git help init (for *init*, you can use
any code you want to know about)
· Now we have to track our untracked “index.html
file”. For that type, $ git add index.html
·
Then the file comes to the staged area.
· Now we have to move the file to the committed
area. For that type, $ git commit -m "added html file"
·
If you want to track more than one untracked
file, type $ git add .
· To see your commits, type $ git log
·
$ git diff
·
$ git diff –staged
·
$ git diff head
With these 3 codes, we are going to see the difference
between each stage.(what is newly added)
Let us meet with git - github (part 02)...