Know About GIT !

What is git?
Git is a free and open source distributed version control system.

Installation of git in Ubuntu:

$sudo apt-get install git 
You can check whether the installation is successful by:
$which git
Git records your name and email address with all your commits so first you have to do:
$git config --global user.name 'Your name'
$git config --global user.email 'Your email id'
and you can see the settings with this command:
$cat ~/.gitconfig

First to work with git you need a Git repository. Which can be made either by cloning from an existing public Git repository or by initialising a new reposiory in a directory using the command:

$mkdir Project

$cd Project

$git init 
This will create an empty repository in /path/Project/.git .
If you want to work on an existing project and use its source code then you can clone it by:
$git clone "https://github.com/username/repositoryname.git

git

The local repository consists of three “trees”:
1) Working directory – where the actual files are located.
2) Index – the staging area, ie where the changes are stored before the commit.
3) Head – It points to the last commit that has been made.

Commands in git :

$git add – It adds file to the staging area which is place to store the changes before commit.
$git status – It shows the status of the files in the working directory and staging area.
$git commit – Records the snapshot of the staging area, ie. all the changes are recorded. For adding the commit message while doing commit in the command line the following command is used:
$git commit -m 'My First Commit'
$git diff – Show the changes that have been made in the project after the last commit, which is not staged.
$git rm – It removes the file from the staging area which was added by using git add.
git2

The above things are done in a local repository. If it is to be shared among other people it should be added to a remote repository. To connect to a remote repository we use the following command:

$git remote add origin [url] 

To push the contents to the remote repository do:

$ git push -u origin master

$git fetch – Fetches new data from the remote server.

$git pull – It also do the same function as that of fetch. It differs by merging the data into the current branch.

git3

Git supports another great feature called branching. Branching helps in adding changes to the existing code without disturbing it. It has many use.  I will write about branching in git in another post.

First Step to Contribution – Building a Custom Firefox in Linux Distro

 Firefox-logo
Building custom firefox is very easy in Linux Distro but that main thing to keep in mind is that all the pre-requisite packages should be installed first. And that too is easy. It is just about few lines of commands 🙂
Actually the Developer guide has explained everything, only thing is you have to search the appropriate place.
To install all the system dependencies the following one line command is used:
wget https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py && python bootstrap.py
If it shows an error like wget: command not found then you can install using curl.
curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py > bootstrap.py && python bootstrap.py
If this too doesn’t work then you can download the file from here. And then run it using:
python bootstrap.py
For Ubuntu all the pre-requisites can be installed using the command:
sudo apt-get install zip unzip mercurial g++ make autoconf2.13 yasm libgtk2.0-dev libglib2.0-dev libdbus-1-dev libdbus-glib-1-dev libasound2-dev libcurl4-openssl-dev libiw-dev libxt-dev mesa-common-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libpulse-dev
Next step you can do in two ways getting the source code. Either by downloading the bundle or getting the source code directly by cloning. But the latter will be too slow.
i) Get the latest source code from Mozilla’s Mercurial code repository using  the command:
hg clone https://hg.mozilla.org/mozilla-central
ii) You can get the up to date bundle for Mozilla central from here.
After dowloading the repository bundle follow these commands:

1) Create a directory and initialise a new repository in that directory:

mkdir mozilla-central</pre>
</div>
<div style="padding-left: 30px;">hg init mozilla-central
2) Go to that directory
cd mozilla-central
and unbundle the source code to that repository:
hg unbundle /pathtoyourbundle.hg
3) For getting the changes and updating the souce code in the future you have to add the following command to mozilla-central/.hg/hgrc
[paths]</pre>
</div>
<div style="padding-left: 30px;">default=https://hg.mozilla.org/mozilla-central/
4) Check the bundle integrity and update the bundle:
hg pull</pre>
</div>
<div style="padding-left: 30px;">hg update
Now you have a clone to the Mozilla central like the one you got by doing hg clone.

Now it’s ready to start the build. The command to start the build is

./mach build

You can run the custom firefox by giving the following command:

./mach run

You did it…now you have your own custom firefox 😉

You can keep track of everything that is done during the build by using the command:

./mach build &> temp.txt

If the build fails it’s a normal thing to happen. Build will not work at the first attempt itself.

  • If you are doing the build in a virtual box the main problem that is faced is the memory usage you can check the memory usage by typing the command free.
  • For clearing older build works type the command
make clean -f client.mk

or

./mach clobber

Now you have the source code with you…make your contributions.