Skip to main content

Introduction to GIT and GITHUB


In this series I would be covering the basic operation of  GIT so that even a new comer can easily feel comfortable with the terminologies and usage of git system.

The first post is just a brief introduction that will help you clarify the questions raising about this new thing.





What is a Git?

  • Git is simply a software that helps you manage your source code.That means each change that you make to a source code is recorded in its history.So it can also be called as Source Code managemnt system.

  • To use git for a particular project all you need is to initialize the current project folder so that it will be tacked by the git system.I will show it in further documents about how to do it.
  • Every Git working directory(or you can say your project folder) is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.

What is GitHub ?

  • In layman terms you can think of GitHub as a social network of source codes and by that means here you can host all the projects you have made online with facility to make them private or public . Each project that you host can have one or many files .

  • In git terms each hosted project is called a REPOSITORY.

Why should we use Git and Github ?
  • The power of GitHub is that is facilitates collaborative work.That means suppose i have a repository on my github account.So now any one can just clone it (NB: Cloning creates a exact copy of project on local machine i.e your laptop ) and make changes to the existing source codes i.e add something new or delete something or make any changes to the source code.
  • Ok now after doing this you would like to show what you have done to the owner of the project.So it can be done using PULL REQUEST(similar to sending friend requests in FB).By that it means you are asking the project to go through the new code and changes and finally decide if is nice enough to get merged(Getting merged means the changes you made would be mixed with the existing code to create a new one).

  • Git and GitHub are both intelligent enough to show the differences (i.e the canges made to the code).

What is branching and why is its used?


  • Branching is a very powerful feature of git.What it does is ,that allows you to take a piece of code and branch it to create a new feature without affecting the original code.
  • What we do in branch branching is that ,we develop a new feature in each branch so that if something goes wrong we can just delete the branch without affecting other
  • And How is it helpful??
    Lets consider we have a Project1 hosted in our GitHub and there are two persons A and B.
    Now A has got some idea and B has got some idea to add a new feature to the project1 ,but these ideas are independent of each other.So what they do is both of them clone the project1 to their respective laptops. After cloning so each of them has master copy of the project.And from that master copy they create a branch which has all the same code as master.In that branch they make changes respectively.Lets call branch of A as Branch-A and branch of B as Branch-B.After making the changes now A send this branch as a pull request and after that B send his branch.
    So now see Project1 has got requests for additions for 2 new features from 2 different developers.Now the owner just have to check that if the code is fine or not and will allow the merging of code.
  • Infact another instance is ,suppose A has two ideas in his mind and want to work on both simultaneously.Now that he has cloned the main project ,he can create 2 different branches that has exactly the same code as master.And now he can work on both of them separately while git takes the headache of maintaing the history of complete project .

Note that i mentioned about history.History is maintained in form of commits.Each commmit describes some addition,deletion or change. After completion of all work history is rebased (it means all the commits are sequenced to create a final timeline of history) to create the final version of project.

So what ever you do in your project ,everything is recorded some where internally in Git.You can think of it as git as a timeline that has a pointer above it that points to current stte of project.You can use the git command to move the pointer forward or backward in history.


So in the next part i will be explaing how to setup Git and GitHub.Stay tuned.And its a kind request , do install ubuntu on your machines and dig around with the terminal as much as possible.

Comments

  1. I started using git recently and this blog post helped me get acquainted with the basics of git and github. Thank you! :)

    ReplyDelete
    Replies
    1. You are most welcome.Glad it helped. :)

      Delete

Post a Comment

Popular posts from this blog

Difference between spin locks and semaphores--Some Notes

up vote down vote accepted Both manage a limited resource. I'll first describe difference between binary semaphore (mutex) and spin lock. Spin locks  perform a busy wait - i.e. it keeps running loop(In turn heavy CPU usage example is in Reactor usage of AsyncTaskExecutors): while (try_acquire_resource ()); ... release(); It performs very lightweight locking/unlocking but if the locking thread will be preempted by other which will try to access the same resouce the second one will simply try to acquitre resource untill it run out of it CPU quanta. On the other hand  mutex  behave more like: if (!try_lock()) { add_to_waiting_queue (); wait(); } ... process *p = get_next_process_from_waiting_queue (); p->wakeUp (); Hence if the thread will try to acquire blocked resource it will be suspended till it will be avaible for it. Locking/unlocking is much more heavy but the waiting is 'free' and 'fair'. Semaphore  is a lock that is allowed to

Write a program such that given a BST,return the size of largest subtree that lies within a given range[a,b].

Write a program such that given a BST,return the size of largest subtree that lies within a given range[a,b]. N.B: This  exact question was asked in a Google interview.  This problem when looked at first looks simple and may be for some it it but for me when it wasn't because when I started coding it I got all confused between recursions and the flow the algorithm will take.So i started simple on pen and paper tried for a couple of hours and could make it work . Point to be noted here is that the following approach here I took is not the most  efficient way but yes it does works perfectly. Steps or rather my thoughts : I had to touch each node so that I can calculate the size of the subtree in case the tree below and the node itself lied in the range.And after i calculate it I have maintained a global variable that stores the current max and when new value comes it compares it with existing one and updates it with the max value between them. To do so ,we