Git is a source code management system. It was basically developed by Linus Torvalds.It is a open source distributed version control system (DVCS).
Advantages
1. Here data which presents on your local machine mirrors the data in GitHub repository, hence chances of data loss are very less.
2. As the name "version control system" indicates, we can manage various versions of same project, and also helpfull to reverse or backtrack the changes.
3. A group of people can work together, all using the same files. Files are stored on Github, every team members can download these files and work locally i.e. on the same project.
Installation on windows
You can download and install it from this link: Git For Windows
As GUI is also available, but I prefer the command line.
Lets introduce myself to the Git. Run the following commands on your terminal i.e. on GitBash
Syntax:
git config --global user.name "Enter your name here"
git config --global user.email "Enter your mail id here"
git config --global user.name "Enter your name here"
git config --global user.email "Enter your mail id here"
Here is a example code:
$ git config --global user.name "sukhesh"
$ git config --global user.email "sukhesh222@gmail.com"
Lets create our local project directory "myProject" using following commands
$ git config --global user.name "sukhesh"
$ git config --global user.email "sukhesh222@gmail.com"
$ cd c:
$ cd xampp
$ cd htdocs
$ mkdir myProject
$ cd myProject
$ cd c:
$ cd xampp
$ cd htdocs
$ mkdir myProject
$ cd myProject
Lets initialize the Git:
Assume it contains 2 files (index.php, jsonLogin.php) and two folders(css,js). For demo purpose I had created these files in "myProject" folder. Now, lets initialize the Git in this folder. Hit the following command :
$ git init
$ git init
Now you can see .git folder has created inside "myProjects" folder.
Adding files to the staging area:
Now you need to add files to the staging area. Staging area is a place which holds the files ready for next commit. So that you can commit those files/folders.
Either you can add all the files/folders at single shot to the staging area using "git add ." command or you can also add individual files as shown in the below example
$ git add .
$ git add .
You can add individual files as shown below:
$ git add css
$ git add js
$ git add index.php
$ git add jsonLogin.php
$ git add css
$ git add js
$ git add index.php
$ git add jsonLogin.php
Checking the status
Now you have been successfully added your files to the staging area. You can check it using "git status" command
$ git status
Commit command
Now you can commit the files by using following command
$ git commit -m "some description about commit comes here"
$ git commit -m "some description about commit comes here"
Here is a demonstration code:
$ git commit -m "committing the initial changes"
$ git commit -m "committing the initial changes"
No comments:
Post a Comment