Everything About Git Part: 2

Git Installation and Configuration on Computer

In order to start working with Git, you need to make your computer suitable for using Git. That’s why you need to install Git on your computer. Let’s take a look at how to install and configure Git on different OS.

Windows:

1. Click here to download the Git package.
2. Click on the downloaded file to install it.

Mac OS X:

1. Click here to download the Git package for Mac OS X.
2. Click on the downloaded file to install it.

Linux:

There are different ways to install Git for different Linux distros. But very simple. Enter the following commands in the terminal according to the distro.

  • Debian/Ubuntu
    1
    # apt-get install git
  • Fedora
    1
    # yum install git
  • Gentoo
    1
    # emerge --ask --verbose dev-vcs/git
  • Arch Linux
    1
    # pacman -S git
  • FreeBSD
    1
    2
    $ cd /usr/ports/devel/git
    $make install
  • Solaris 11 Express
    1
    $ pkg install developer/versioning/git
  • OpenBSD
    1
    $ pkg_add git

Git Configure

I assume you have Git installed on any of the above OS. Now you need to configure Git. And the main purpose of this configuration is that when you commit through Git, he will store your information with Comit. All you have to do is enter your username and email address during the configuration. After Windows users install Git, a shortcut file named gitBash will be created on the computer desktop. You can open it and write the following commands in it. Or you can run the commands directly on the CMD if you want. Linux and Mac OSX users can type commands in the terminal.

1
git config --global user.name "Your Name Here"

Enter your name in place of Your Name Here.

1
git config --global user.email "your_email@youremail.com"

Enter your Email Address in place of your_email@youremail.com.

Make sure that the email address you enter here matches the email address of your server account. Now your computer is ready to use Git. From now on you can use Git commands on your computer. We will write all our commands in gitBash, CMD or terminal.

Configure different git for different projects

Suppose you want to have multiple names and emails for multiple projects. That means you have an office project on your PC and you have a personal project. The office project is kept in your office’s GitHub account. You access that account with your office email. Again your personal GitHub account was opened with your personal email. If your project has a global username and email set, but all projects will show the same name and the same email. That’s why you can no longer use global usernames and emails. Now you need to cut out the global keyword and its previous hyphen. And the commands will be as follows:

1
2
3
4
5
6
7
//Git is configured using an email for the first project
git config user.name "Tortoiz Themes"
git config user.email "tortoizthemes@gmail.com"
//The second project has been configured with another e-mail
git config user.name "Tortoiz Themes"
git config user.email "tortoiz@gmail.com"