Enough Git and GitHub that every programmer should know.
Part-1:-Setting up our project.
Before I start I want to tell you all that this "Git and GitHub" tutorial will be divided into four parts. This is the first part of this tutorial.
Whether you are an aspiring web developer, data scientist or you are getting started with programming, knowing git and GitHub is very important. Before we start with the tutorial it is very important to understand that what git and GitHub means as many people tend to get confused between them.
What is Git?
- If you google its definition and click on any article then generally you will see this definition,"Git is a distributed version control system". Now first understand what does the version control system means. It is a system that provides with you the features of keeping a record of your software code changes, who made those changes, and at what time. It also enables you to restore your project to its previous version. Distributed in the terms of git means that a particular software project is not limited or located to any one device and you can clone the entire software project to different machines and do the necessary code changes accordingly. To use git in your system you need to download git bash(an application which runs git terminal line on your operating system) from this link.
What is GitHub?
It is a place that provides you with repository(a place where we store our software project) hosting service on the cloud along with GUI features of git commands. There are other alternatives to this such as Bitbucket,GitLab, and SourceForge however GitHub is most popular and widely used. You can create your GitHub account by visiting github.com.
Configuring git:-
Now I hope that you had installed git on your local machine and now it's time to fire up your git terminal for configuration.
To configure git you need to run the following two commands in your terminal๐๐
git config --global user.name "Your username"
git config --global user.email "youremailaddress@example.com"
Here the global keyword means that you are setting up your email and username for git and it will use the same username and email to commit your changes across all the repositories you clone or create on your system.
Configuring git with your GitHub account using SSH keys:-
Whenever you want to commit any changes to your project git will always ask your GitHub username and password which can be quite overwhelming sometimes. To prevent this you need to configure git with GitHub using SSH(a protocol that encrypts communication between two computers) keys. Here is a detailed blog by freeCodeCamp regarding this.
Repository:-
It is a place where we store our software project. Now visit github.com and log in to your account. Once you are done with it then you can see this page.
On the right, you can see that people I am following (name and profile picture has been colored for privacy reasons) are forking(creating a copy of somebody's else project into your GitHub account),cloning(creating a clone of a project into your local machine), and starring projects(the equivalent of liking a project or adding it as a bookmark).
On the left side of the page, you can see the repositories which are created or forked by me, and a new button that I encircled with red color.๐๐๐
Click on the new button and you will be directed to this page๐๐๐
One thing you might be noticing that before creating your repository is that there are options on whether you want to keep your repository public or private(in public anyone can view or commit changes to your repository and in private you decide who can view or commit changes to your repository ) there are other options as well such as adding a README.md file (it is like a manual which contains information about your project), adding a .gitignore file(it specifies which files you do not want to save or push to Github) and adding a license(it gives you the choice to choose a particular type of license with certain terms and conditions on how you can use that open source project). Now just type the name of the repository you want to name and click on the Create repository button and congratulations๐ your first repository is created.
Cloning:-
Now the repository which you created right now is your repository on cloud(GitHub) or remote repository to be more specific. Now you cannot build any project just by creating a repository of it. You need to clone that repository to your local machine to start building it for which the git clone command comes into the picture. ๐๐๐
Syntax:-
git clone <url of repository>
To get the URL of the repository you need to copy the link of your repository as shown below๐๐๐
Now fire the git terminal on your local machine and type these commands as follows๐๐๐
Now you know what git clone does. cd command stands for change directory as it helps you to traverse from one part of a file to another and code . command is used to open visual studio code editor.
That's all for this blog. The second part of this tutorial will be released soon. If you found my content useful then consider supporting me on "Buy Me a Coffee".
Thank you for reading :)
Update:-
Part-2 is out. Go check it out over here.