Git and GitHub in a NutShell.. What is Git and Why should we learn it? | by vineeth kanaparthi | codeburst

Git and GitHub in a NutShell.

vineeth kanaparthi
codeburst
Published in
4 min readFeb 14, 2018

What is Git and Why should we learn it?

Git is a VCS — Version Control System. What that really means is, Git helps us manage our project files. One of the primary things that git does and also the primary reason it exists is to keep track of the entire history of things that you are working on.

This is especially helpful for software developers because when you are working on a project you first build a basic version of it and then try to improve it by adding new features (or) just experiment with things. This whole process of experimenting with new features is incredibly error prone and you might wanna revert back to your original code.

This is where Version Control comes into play, it automatically tracks every minute change in your project and allows us to revert back to a previous version no matter how many times you changed your files.

Another awesome thing that Git allows to do is, it allows people to work together on the same project at the same time without disturbing each other’s files. Collaboration is all the more easier with Git.Team members can work on different features and easily merge changes.

Git is easy to learn and has a lightning fast performance. It outclasses other Version Control Systems like SubVersion with features like cheap and local branching, convenient staging areas and multiple workflows.

GitHub

GitHub is a web-based service for version control using Git. Basically, it is a social networking site for developers. You can look at other people’s code, identify issues with their code and even propose changes. This also helps you in improving your code. On a lighter note, it is a great place to show off your projects and get noticed by potential recruiters.

In short, Git is Version Control System and GitHub is a hosting service for Git Repositories.

Some Basic Terminology

Repository: A Git Repository, or a repo, is a folder that you’ve told Git to help you track file changes.

Branch: A branch is an independent line of development. You can think of it as a brand new working directory.

Fork: A fork is a personal copy of another user’s repository that lives on your account.

Clone: A clone is simply a copy of a repository that lives on your computer instead of on a server.

Commit: A commit is a set of one or more changes to a file(or a set of files). Every time you save, it creates a unique ID(“hash”) which helps it keep track of the history.

Master: The default development branch. Whenever you create a git repo, a branch named “master” is created which becomes the default active branch.

Installation

Windows

Download and install Git for Windows. Once installed, you’ll be able to use Git from the command prompt or PowerShell.

Git for Windows does not automatically update. Update it by downloading the newer version of it.

macOS

Install Homebrew and run the following to install an up to date version of Git on your Mac:

> brew install git

To update your Git install, use Homebrew’s upgrade option:

> brew upgrade git

Linux

Use your Linux package management system to install Git. on Ubuntu:

> sudo apt-get install git

Configure Git

Run the following commands from the command prompt after installing Git to configure this information:

> git config --global user.name "user name"> git config --global user.email "user email"

Git Commands

Use the git init command to create a new repo from an existing folder on your computer. From the command line, navigate to the root folder containing your code and run

> git init

with git add . move changes from the working directory to the staging area.

> git add .

git commitTakes the staged files and commits it to the project history. Together with git add, this saves your changes in the main repo.

> git commit -m "commit message"

Use the git clone command to copy the contents of an existing repo to a folder on your computer. From the command line, navigate to the folder you want to contain the cloned repo, then run:

> git clone (URL of the repo)

create branches using the git branch command:

> git branch <branchname>

Use the git push to save your changes on the server.

> git push origin <branchname>

To keep the local repository in sync with the remote repository

> git pull origin master

There are a lot more commands to learn but these are enough to get you started. You can pick up the rest of the commands as you explore and use git and GitHub more.

As a small task, go to github explore, find a project that interests you, clone it and run it on your computer. It can be anything, a big project like Vehicle detection or even a small one like a web crawler. Furthermore, try understanding the code.

Resources

DataSchool Playlist

Next in line

Making your first Contribution.

If tutorials like this interest you and you want to learn more, click on the clap button few times to show some love.

--

--

Responses (3)