- A beginer's guide for Git & GitHub
All the excitement and hype over Git tend to make things a little muddy. You all may have many questions, such as, can you only use Git to share your code with others, or can you use Git in the privacy  of your own home or business? Do you have to have a GitHub account  to use Git? Why use Git at all? What are the benefits of Git?
Is Git the only option ?
So forget what you know or what you think you know about Git and let's take it from the beginning.
Git is, first and foremost, a Version control system (VCS). There are many version control systems out there: CVS, SVN, Mercurial, Fossil, and, of course, Git.
By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project initially developed in 2005 by Linus Torvalds, the Linux operating system kernel’s famous creator. A staggering number of software projects rely on Git for version control, including commercial projects as well as open-source.
So now, let’s see what exactly git is. Git is a distributed version control system. So, What is a Version Control System?
A version Control system is a system that maintains different versions of your project when we work in a team or as an individual (system managing changes to files). As the project progresses, new features get added to it. So, a version control system maintains all your different versions of your project for you. You can roll back to any version you want without causing trouble to you for keeping versions distinct by giving names to it like HelloWorld, HelloWorld_v_1, HelloWorld_v_1.1, etc.
A distributed version control system means every collaborator (any developer working on a team project) has a local repository of the project in his/her local machine, unlike central, where team members should have an internet connection to update their work a principal central repository. So, by distributed, we mean: the project is distributed. A repository is an area that keeps all your project files, images, etc.
Local Repository: This is your local repository where you commit changes to the project before pushing them to the central repository on Github. Local Repository is what is provided by the distributed version control system. Local Repository corresponds to the .git folder in our directory.
Now, Let me tell you that you can use Git GUIs (Graphical User Interface), which is super-easy, But then you won't be doing justice to your Programmer's Pride. Well, in that case, we use Command Line Git.
P.S. It's not just about Programmer's Pride, and Command-Line Git also provides much control over various functions, which we will discuss ahead. So, Let's Get Started.
So, first of all, you need to install Git on your system. You can get the Installation Guide here. Now, Create a free account at GitHub.
Want to check if Git installed successfully or not?
This command will return the version of git in floating digits, which verifies that Git has been installed successfully.
Git   is a free and open-source distributed version control system designed to handle small to substantial projects with speed and efficiency. It is used to track all the changes that you made to your code and revert to a particular version if you want to. Git also makes collaboration more comfortable, allowing changes by multiple people to all to be merged into one source.
On the other hand, GitHub   lets you store your code on a cloud server easily accessed by other programmers online. It’s an online database that allows you to track and share your Git version control projects outside your local computer/server.With a basic knowledge of git and GitHub, let's move forward.
A Git repository is the .git/ folder inside a project. This repository tracks all changes made to files in your project, building history over time.
First, open up a terminal and move to where you want to place the project on your local machine, and right-click to open Git BASH Here.
To initialize a git repository in the root of the folder, run the git init command:
Before we add a file, let's see the basic workflow :
So, in order to proceed with this tutorial, create a file named index.txt. This file is currently in the working area. Now we will add this file to the staging area using the git add command, followed by the git commit command to commit the changes:
Commit messages are very important in the long run. Later if you want to revert back to a certain version, the commit message makes it easier for us to remember the version.
We use the git status command to check which files are in staging area, and which are untracked file:
This step is really simple and self-explanatory. We just have to open our newly created GitHub account. And then Click on NEW   Repository. You can choose the name of your repo, the accessibility and provide some description. Click Create Repository and voila, your repository is created!
The git push command is used to upload local repository content to a remote repository. Pushing is how we transfer commits from our local repository to a remote repo. It's the counterpart to git fetch, but whereas fetching imports commits to local branches, pushing exports commits to remote branches.
To push our local repository, we connect our Git to the GitHub Repository :
You have successfully learned :-
Author
Reply
Leave a comment