Wednesday, 19 September 2012

How to install git in ubuntu?

If you are in Debian-based distribution like Ubuntu, execute following line in terminal.

sudo apt-get install git-core

OR


In, GUI


System->Administration->Synaptic Package Manager.
Write 'git-core' in search box -> select 'git-core' -> Mark for Install -> Apply.
Wait till install successfully completed.

Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. You should have to do these things only once.

Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places as per requirement means 

System wide visible variable(visible to all user in that system), 
Global variables for One user(visible to one user), 
Local or File or Working Repository visible variables(visible to only working repository). 

  • /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option--system to git config, it reads and writes from this file specifically.
  • ~/.gitconfig file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.
  • config file in the git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository. Each level overrides values in the previous level, so values in .git/config trump those in /etc/gitconfig.

Setup Your Identity

The first thing you should do when you install Git is to set your user name and e-mail address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you pass around:
 
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

Setup YourEditor

git config --global core.editor vim

Setup Diff tool

git config --global merge.tool meld

The above setting are most common and important settings for git. You should do it once and conform your setting using following command.

git config --list


You may see keys more than once, because Git reads the same key from different files (/etc/gitconfig and ~/.gitconfig, for example). In this case, Git uses the last value for each unique key it sees.
You can also check what Git thinks a specific key’s value is by typing git config {key}:

$ git config user.name

 
It will list all your setting you can update again if needed.





No comments:

Post a Comment