Learning Git

Souvik Haldar
Jul 10, 2017 · 5 min read

Today I’m going to discuss about Git and Github and how one can learn it in no time as a part of my ongoing internship with Hasura.

So Git is a open-source distributed Version Control System (VCS) which is used to keep track of the changes made to a file (it can be of any type)on a computer. It is tool which allows several developers to work on a project collaboratively in an efficient manner.

On the other hand,Github is the Git repository hosting system. It is used to host the repositories created by us online for Source Code Mangement (SCM) and distributed rivision control that the tool Git provides. Github and Git are independent entities which can work independently.

Now let me explain the steps involved to learn Git.

Installing Git on linux:-

  1. To install git on linux you can run the following command in the terminal.

2. After installation you need to configure it with your credentials. You should have your email ID and username handy and if you don’t have an account on Github then create one.

so to configure it run the following commands on your terminal.

i) To configure user name:-

ii) To configure email ID:-

3. Now that you have configured Git successfully next you need to create your repository (a place to store your files).

Go to Github and create a new repository and fill the required details.

4. To get the repository on your local machine many ways can be used by I use this way:-

Clone the repo on your local computer in a newly created directory by copying the link to the repo :-

Now run this command:-

You can now see that repo is now available on your computer in the given directory.

5. Now you can create new files or edit previously available files in this folder and those will be backed up by git as various versions and commits.

Let me explain this by creating a new text file called “sample.txt” and committing the same to the Github repository.

Here I have created a file named ‘sample.txt’ by the command:-

touch sample.txt

Then after writing something to the file I’ve added this file to git in the staging area.

After the addition you need to commit this change. For doing this following commands are required:-

git add sample.txt

git commit -m “this is the first file”

After the change has been commited it needs to be pushed to the repository. For pushing this change to the repo you need to run this command:-

git push origin master

(since we are in the master branch)

Now if you visit this repo on github you can see for all the changes along with all the required information.

You can always run “git status” to see the status of your repo.

But when many people are working on the same repo, they are highly likely to step on each other’s toes. In order to avoid this conflict we choose to branch out. In this concept, branches are drawn out of a repo, and when these changes are approved, they are merged with the master branch (main branch).

To create a new branch and then enter into this branch for commiting further changes following commands are used:-

git branch newBranch

git checkout newBranch

Once you have entered into this new branch, you can further your work in this branch. Once you are satisfied with your work in this branch you can merge it with your master branch by the following way:-

Here we created a new filed named ‘hey.txt’ in the newBranch branch and then added and committed it. Then we switched to the master branch again. Then we merged the newBranch with master branch by using git merge newBranch. Once all these are done we simply push it to the master.

Optional:-

By now you must have observed that every time you try to push to the master your credentials are required. This is quite irritating. In order to get rid of this you can follow the given link.

Link

After you have generated a SSH key you need to add this generated SSH key to you github account. (described in the link)

You might need to install xclip for pasting the generated ssh key to the clipboard from where you will further paste it in your github account.

my ssh key have been added

Now you can simply push the changes to the master without the need of credentials.

So now with this knowledge in hand you can do basic operations in Git. Welcome to the world of developers!

Index of contents in this web-app development series

  1. Idea of the app — Hisab-Kitab: Save to Earn
  2. Prototype of the app
  3. Setting up the development environment
  4. Learning Git
  5. Setting up local development setup
  6. Data model of the app
  7. Hasura Data API + Postman collection
  8. Hasura Auth API + Postman collection
  9. App Screen 1 (UI + Backend integration)
  10. Updates
  11. App Screen 2 (UI + Backend integration)
  12. App Screen 3 (UI + Backend integration)
  13. User feedback and Testing
  14. Final app link

Souvik Haldar

Written by

Backend Developer. Fitness Enthusiast.Learner. https://souvikhaldar.info

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade