In this article we will talk about git and github, if you do coding then this is a very important topic for you. Both git and github are different tools, their work is totally different from each other.
Git is a version control system. Which keeps information of any change in our files. Which we can easily revert or undo.
For example- if you have a project in which you change any code and because of that any problem or bug is created and if you need old file, so you can do it easily with the help of Git command . with the help of git many coders can code simultaneously on a given project from anywhere.
let's know how to install git in your PC.
Step 1 - Open git-scm.com in your browser and Click on downloads.
Step 2 - choose your operating system And download the file.
Step 3 - Install the downloaded file.
Step 4 - Open the terminal or command to check whether the installation process is completed correctly or not.
For check open terminal or command prompt and then type version of git on it.
If your window is opening, then you have installed the Git correctly , otherwise you can google it for take its solution and install it again.
To use Git you will need a terminal and a command prompt from which you can run the Git command. take the location of the folder on which you want to use Git and type.
$ cd folder location
in the terminal, by doing this, you create directory of that folder and then any command you run in the terminal will be valid for that folder only.
→ Git init
$ git init
Using Git init we create an empty Git repository. Before using any git command, we need to initialize the git of that repository.
→ Git add
$ git add .
For all files that you use in the project, we need to move it to the staging area, for that we use the git add command.
→ Git commit
$ git commit -m "commit massage in quote"
After moving the files to the staging area, we use the Git commit command to create a checkpoint and along with it give a committed massage so that we know what we have changed or added on this commit. Every checkpoint has a unique code, with the help of that we can come to that checkpoint at any time.
→ Git status
$ git status
With the git status command, we know about all the changes that have been made so far.
→ Git branch
$ git banch branch_name;
With the help of git branch command we can create a new branch.
For example- if we want to create a branch named abc then we will type - git branch <abc> and then branch will be created.
→ Git checkout
$ git checkout branch_name;
By using git checkout command, we can move from one branch to another ,if we had created a branch named abc earlier but now we were only in the master branch, we need to run git checkout <abc> command to go to abc branch . Which will bring us to the abc branch.
→ Git merge
$ git merge branch_name;
By help of Git merge command, we can merge any branch which present in your Git.
For example- If you are currently in master branch and we have to merge abc branch in master branch then we will run git merge <abc> command.
Note : there are many Git command which we discuss in another article or you can google it.
Github is an online platform where we can save our created project online. With the help of which we can access our project from anywhere at any time. Github also called as a social media platform of coders where many coders can work together on team work. More than fifty million coders will be work on Github. By using Github we can easily connect and work with them. We can connect Github to our computer with the help of git command.