hacktoberfest

Hmm, Git, one of the most tools for software engineers. Before explaining about Git, Let’s know what is the version control system.

Git

A system that records your file changes so that you can recall specific versions later. Let’s say you are right now at top renown company and you are writing code but you forget to add one feature which you missed or you wanted a beta version of your code. Now, what you will do? Will you able to have your beta version of your code? What’s the solution? You might get a solution by getting a backup of your previous code. But wait is that the better approach. No, it’s not. It’s time-consuming.

In this case, a version control system can recall your previous beta code and go further in your project. You can revert the entire project to a previous beta state too.

May be another new blog articles, I will be sharing about types of a version control system, we didn’t learn today about it but glad to know after learning myself about it. Git is one the version control system which can able to solve the problems of a software engineer and other tech professionals. There are other alternatives to Git too.

Learn Git and GitHub 101 - Crash Course 1

We knew about the version control system. Git is one of them that helps you to manage projects. Let’s get into practice. First of all download the git on your system.

Learn Git and GitHub 101 - Crash Course 2

After you installed on your machine, check the version of git.

Learn Git and GitHub 101 - Crash Course 3

After that, let’s follow the below commands.

Learn Git and GitHub 101 - Crash Course 4

Here, we used mkdir to create a new directory called day2_git and cd to change the directory. We initialized the git repository by git init in our project. If you feeling unknown about few commands, don’t worry we will discuss later that.

Learn Git and GitHub 101 - Crash Course 5

we created a file called main.py using touch and edited file. One more thing for you, git might feel difficult at first but once you learn it, you never want to go back to anything less flexible and powerful.

Ooho I forget to mention to configure the git on your machine. Let’s configure git. Before configuring git, I prefer you to create an account in GitHub too. It is easy to create an account in GitHub. Use your name which you had used in GitHub account and email too.

Learn Git and GitHub 101 - Crash Course 6

You can set up ssh on your computer too. Let’s not get into ssh and go through as quickly as possible to quickly push your code in GitHub. Edit the main.py

Let’s check the status of main.py

Learn Git and GitHub 101 - Crash Course 7

git status commands help you check the status of the git repository. Oh no, our file hasn’t been tracked let’s track by simply using git add command.

Learn Git and GitHub 101 - Crash Course 8

We tracked the file and checked again too. Now, it’s time to reference the tracked file by using git commit.

Learn Git and GitHub 101 - Crash Course 9

wow, you did it. You knew a few basic git commands. Let’s learn what is GitHub and push your code into it.

Learn Git and GitHub 101 - Crash Course 10

GitHub is a git repository hosting service and it’s the platform where you can host your local repository into the cloud. It has an awesome UI and provides many features. Lots of companies use GitHub for their organizational purpose. You have to know that GitHub is not the only Git hosting platform, there are others too like Git lab, Bit bucket, and many more. You had already created an account as I mentioned earlier.

Let’s create their repository and push our local repository to cloud one.

Learn Git and GitHub 101 - Crash Course 11

You created your first repository in GitHub. Awesome.

Learn Git and GitHub 101 - Crash Course 12

Here, it says to create a new repository on the command line. But we had already done it. So we will push our existing repository. We will follow below command using git remote add origin https:// and push to our default branch called master.

Learn Git and GitHub 101 - Crash Course 13
Learn Git and GitHub 101 - Crash Course 14

And you finally push to your file in GitHub. You can also create an issue when you have problems with that particular repository.

I have a reference example of an issue from the dev.to opensource project. Here it is.

Learn Git and GitHub 101 - Crash Course 15

If you wanted to contribute to the existing opensource project. You can send out Pull Request. It’s the best part of GitHub which enables friction less collaboration among millions of developers. .Pull Requests let you tell the opensource project maintainer about the changes you made and wanted to push to their repository. Here is the sample of creating a pull request.

Learn Git and GitHub 101 - Crash Course 16

We learned basic stuff on Git and GitHub. It’s getting better and better as being a software engineer trainee. I didn’t share about lots of GitHub features which I will share in upcoming articles. Thank you.