Skip to main content

Learn Git & Github

Learn Git : Lesson 1

Why Git or any VCS

git logo
Image from git-scm

Version control system is a software which maintains the records of changes done to a project and also the states of the project which you can switch anytime. As a programmer, it sometimes happens to me when i write a piece of code and it works but when i try to optimize it then it gets broken. Also i could not be able to traceback the changes and get my working code back. If this happens to you also then you might undo tens of times to get back the previous code.

But what will you do if your project contains multiple files with hundred lines of code in each file. If you now brong some changes to more than one file then its not easily possible to get back the working code. Here comes the importance of a version control system. In a VCS, you can save the current state and continue to work on a different state but it doesn't mean that vcs creates a copy of the current state. No. It maintains the record of the changes bring to a project. It maintains a history which you can navigate to get what state you want.

About this guide

Git has becoming very popular nowadays as the open source softwares are emerging in the market so a lot of developers want to know what exactly git is. Not only knowing about the git, learning and understanding it is also needed to develop large softwares/products with a team. There are many tutorials, guides, video lectures are available to learn git then why this one more guide ? The reason i am writing this guide is that after learning git from various guides, we'll still be wandering stackoverflow to get help for our unique scenarios. So what's wrong with other guides ?
All other guides lack one common thing, User perspective. Many of the guides are written to provide the theoretical knowledge of git commands but don't tell the other uses of the same command. In this guide, i'll not only cover the git basic commands, but will also tell you various tips and tricks to get your task done in git. You won't just get to know about git commands but will understand what these commands do and can do. Not only the commands, how git works is also important to understand.
So this guide will make you fall in love with git. Its not that other VCS are not good but i know about only git and other VCS also work in the same way but the syntax gets different. Below is the list of topics, i'll be covering.


Topics
  1. How Git works
  2. Get yourself on Github
  3. Using commands the smart way

How git works

Git and many vcs have such terms in their terminology like branches, commits, head, master etc. We'll use these terms and will see how actually git works.

  1. Branch :A branch is a state of the project on which you are working. For example, suppose you create a project and name it P1.0. Now you want to modify some code without breaking the working code then what you do is you create a branch and name is what you want. Now whatever changes you bring to that branch does not effect the branch P1.0. In this way you can safely work on your differnt branches without breaking anything.
  2. Commit :Saving a change is called commit. If you change something in your branch then you should commit/save it so that it gets recorded it git history. An important advice:- Commits should be small changes. If you have changed a lot in your project and you commit it. Then you find out that it has broken the code then you'll have to write the whole changes again to fix it. Instead of doing large commits, you should change small, commit it, then change small, commit it and so on. This way you can navigate git history to get to the commit where the code seems to broken. 10 smaller commits are much much better than 1 large commit.
  3. Head :Git maintains a pointer called HEAD to the current working branch and commit. When you navigate the git history then what you do is you actually change this HEAD pointer to that branch or that commit. So HEAD is just a pointer.

Git Tree

Now lets have a look at the git tree.

Git Tree

In this tree, you can see that the nodes of this tree are commits which you do in a branch. There you can see 3 branches. In this tree i have a growing branch which has stable versions of my project which are 1.0, 1.2 and 1.6. Then there are 2 branches for testing phase of my versions which are 1.0-test and 1.2-test. The main thing about git is that you can jump between branches and commits whenever you want. In the 3rd lesson, i will tell you how to navigate git history. So stay tuned.


Comments

Popular posts from this blog

Image Search Engine Using Python

Images provide a lot more information than audio or text. Image processing is the prime field of research for robotics as well as search engines. In this article we will explore the concept of finding similarity between digital images using python. Then we will use our program to find top 10 search results inside a dataset of images for a given picture. It won't be as good as google's search engine because of the technique we will be using to find similarity between images. But what we are going to make will be pretty cool. So lets start. Setting up the Environment Our Algorithm How the code looks Lets build the GUI Additional Techniques Setting up the Environment The code we are going to write requires a few tools which we need to install first. I will try to be as precise as i can and if you get stuck into installing some tool then you can drop a comment below and i will help you sort out the problem. So here are the tools and the steps to install

Understanding Python Decorators

If you have ever wondered what those @something mean above a python function or method then you are going to have your answers now. This @something line of code is actually called a decorator. I have red from various articles about them but some of them were not able to clarify the concept of a decorator and what we can achieve with them. So in this post we'll learn a lot about python decorators. Here is a list of topics we'll be covering. What is python decorator Understanding the concept Multiple decorators on same function class method decorator Where can we use decorators What is python decorator A python decorator is nothing but a function which accepts your given function as a parameter and returns a replacement function. So its like something this def decorator(your_func): def replacement(your_func_args): #do some other work return replacement @decorator your_func(your_func_args): #your_func code Now when your_func gets called then

Cordova viewport problem solved

Include the viewport settings in Cordova If you are facing the auto zooming problem of cordova then go read on the full article. Cordova actually ignores the viewport meta tag which causes the pixel density problem. So we need to tell cordova that viewport tag is equally important as other tags. To do this, we need to add some code to a file which is specify in the article. Corodva messes with pixels If you are using the latest cordova version or creating the cordova app for latest android versions then you may have faced the zoom malfunctioning.I also faced it when creating an app. Many of you may have already searched the web and found the answer of changing the meta tag attributes to get it working. But adding target-densitydpi=medium-dpi does not solve the problem for latest android versions. It may work for gingerbread but not for kitkat and others. So the final solution which i found was one of the stackexchange answer but rarely found. So i am gonna two things here, i