Git is the local way of version control system for tracking file changes in your local computer and coordinate the project files between multiple people.
Tool installed for git
There is often GUI software for Git but we will be using terminal window because some of the company prefers those who have knowledge with the terminal window, gain more knowledge and it is not scary as you think. Before moving on, make sure these tools must have to install git-scm.
- On Linux, press ctrl+alt+t to open terminal.
- On Mac, Open terminal window.
- On Window, Search for Git bash to open up a terminal.
Work on project
Git has his own vocabulary that we need to understand.
Repository is similar to the local folder present on your computer.
First, open up terminal ‘Git bash’ window. Type in the command to check whether the git is install on your computer.
In order to start the project, create a folder named “foldergit”. Then type cd into “foldergit” or type cd + space and drag folder onto the terminal and press enter.
To set your account’s default identity, type in the following command
git config –global user.email “email@example.com”
git config –global user.name “Your Name”
Replace “firstname.lastname@example.org” with your email and “Your Name” with your name. This is used to tell that who is doing the project. When multiples people are involved you can tell that which user has done which part of work on the project.
To initialized empty Git repository into the folder, type in the following command.
It is used to create a hidden git folder that will keep track of your file changes.
Now, it is time to create some project. We will create simple web page that will display some content on it. Create HTML and CSS files in the folder and place any code that render some text.
Try to change some files of HTML or CSS, enter the extra line of code in the files, then type in the command
It will show only the files which you have changed in the red color.
In order to move the changed files to the staging area, type in the command
git add -A
All the files move into the staging area will show in green.
Move the files into the destination. commit the changes: type in the command
git commit -m “message for commit”
Change “message for commit” to whatever you like.
Now the fun part, Delete the files HTML, CSS or both, and type in the command:
git checkout — .
After that, the commit for files you have previously changed is restored to your folder.
You can track files changes using Git. and other people can’t access your project as it is saved on your local computer.
Learn server way of version control system, Github.