GIT tutorial Part1

Suppose you are have to write a C code.You will start with writing the code with minimum features then you start adding features one by one .After adding each feature you will check whether your application is working fine.If your application is working fine then no issue,you will continue with the next feature.Suppose your application was working fine ,when you added a feature, so u started adding a new feature,But after adding some of the code of the latest feature,you found that application is misbehaving,now you dont know whether the issue is due to the latest feature or some bug is still present in the previous feature you added,In this scenario versioning tools are most useful.One of the best tools out of it is git.So we will start a tutorial on git ,where we will learning most commonly used commands present in the git.

First step is to install git.
Go to your command line(ctrl+alt+t) and type: sudo apt-get install git

It will first download and will install the git in your system.

So suppose you have a folder named "Project"  in your system,in  which you are writing your C application.

Step1: First go to the folder in which you want the versioning support,

$ cd Project

Step2: If you want to use git in your project,you have to create a git repository,where git stores all the information about your project such as the changes you made,who is making changes and many more.In order to create a git repository type the following command in your directory.

$ git init

O/P:Initialized empty Git repository in /home/jamal/Project/.git/

     Whenever you execute the command , you can see a subdirectory named .git will be created in the folder,in order to see this , type ls -a in the command line

Once you have executed the git init command you have a git repository in your project.

Step3: Once the repository is created,you have to add your files to it, by using the git add command.Suppose there is a file scheduling.c file in your project directory...type the following command

$git add scheduling.c

Step4:Once you have added the file,you can check the status of your repository by typing git status command in your project folder.

$ git status

O/P: A scheduling.c

Step5:You can see there is A  and the file name,A means added,In order to keep tracking it,we have to use the git commit command and you can pass the features you have added to it.

$git commit -m "First commit Message"

Now when you type git status you can see it is clean....

So,this day we have seen four command used by git:

1.git init: To create an empty git repository
2.git add:To add a files into a git repository
3.git commit:To keep a record of your changes in the repository
4.git status:View the status of the files present in your repository




Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto