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?
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.
I started using git recently and this blog post helped me get acquainted with the basics of git and github. Thank you! :)
ReplyDeleteYou are most welcome.Glad it helped. :)
Delete