Wednesday, December 3, 2014

Git: Installation on Ubuntu

Installation


Installing Git on Ubuntu 14.04; open a terminal window and type:
 sudo apt-get install git  


Operational Output

 craigtrim@CVB:~$ sudo apt-get install git  
 [sudo] password for craigtrim:   
 Reading package lists... Done  
 Building dependency tree      
 Reading state information... Done  
 The following extra packages will be installed:  
  git-man liberror-perl  
 Suggested packages:  
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk  
  gitweb git-arch git-bzr git-cvs git-mediawiki git-svn  
 The following NEW packages will be installed:  
  git git-man liberror-perl  
 0 upgraded, 3 newly installed, 0 to remove and 241 not upgraded.  
 Need to get 3,274 kB of archives.  
 After this operation, 21.6 MB of additional disk space will be used.  
 Do you want to continue? [Y/n] Y  
 Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main liberror-perl all 0.17-1.1 [21.1 kB]  
 Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main git-man all 1:1.9.1-1 [698 kB]  
 Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main git amd64 1:1.9.1-1 [2,555 kB]  
 Fetched 3,274 kB in 3s (1,009 kB/s)  
 Selecting previously unselected package liberror-perl.  
 (Reading database ... 168600 files and directories currently installed.)  
 Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...  
 Unpacking liberror-perl (0.17-1.1) ...  
 Selecting previously unselected package git-man.  
 Preparing to unpack .../git-man_1%3a1.9.1-1_all.deb ...  
 Unpacking git-man (1:1.9.1-1) ...  
 Selecting previously unselected package git.  
 Preparing to unpack .../git_1%3a1.9.1-1_amd64.deb ...  
 Unpacking git (1:1.9.1-1) ...  
 Processing triggers for man-db (2.6.7.1-1) ...  
 Setting up liberror-perl (0.17-1.1) ...  
 Setting up git-man (1:1.9.1-1) ...  
 Setting up git (1:1.9.1-1) ...  



Setting your Username and Email

Git uses your username to associate commits with an identity.

The git config command can be used to change your Git configuration, including your username. It takes two arguments:
 craigtrim@CVB:~$ git config --global user.name "craigtrim"  
 craigtrim@CVB:~$ git config user.name  
 craigtrim  
Notice how I was able to confirm the setting in the second line. Also, by using the -global flag, I've set this for every repository on the computer.

I also want to set the email:
 git config --global user.email "craigtrim@gmail.com"  



Cloning a Remote Repository

I want to get a copy of the SWTK commons project so I can look at the code. I'm going to clone the repository in Git. You simply First i'll create a directory for the contents
 mkdir -p $WS/swtk/commons  
 cd $WS/swtk/commons  

Then I'm going to set up a remote which tells Git where the repository is
 git remote add commons https://github.com/torrances/swtk-common.git  

then clone
 git clone https://github.com/torrances/swtk-common.git  

Operational Output

 craigtrim@CVB:~/workspace/swtk/commons$ git remote add commons https://github.com/torrances/swtk-common.git  
 craigtrim@CVB:~/workspace/swtk/commons$ git clone https://github.com/torrances/swtk-common.git  
 Cloning into 'swtk-common'...  
 remote: Counting objects: 770, done.  
 remote: Compressing objects: 100% (139/139), done.  
 remote: Total 770 (delta 44), reused 0 (delta 0)  
 Receiving objects: 100% (770/770), 1.57 MiB | 975.00 KiB/s, done.  
 Resolving deltas: 100% (264/264), done.  
 Checking connectivity... done.  
 craigtrim@CVB:~/workspace/swtk/commons$ ls -lah swtk-common/  
 total 36K  
 drwxrwxr-x 9 craigtrim craigtrim 4.0K Dec 3 17:53 .  
 drwxrwxr-x 4 craigtrim craigtrim 4.0K Dec 3 17:53 ..  
 drwxrwxr-x 2 craigtrim craigtrim 4.0K Dec 3 17:53 build  
 drwxrwxr-x 3 craigtrim craigtrim 4.0K Dec 3 17:53 dependencies  
 drwxrwxr-x 3 craigtrim craigtrim 4.0K Dec 3 17:53 docs  
 drwxrwxr-x 8 craigtrim craigtrim 4.0K Dec 3 17:53 .git  
 drwxrwxr-x 5 craigtrim craigtrim 4.0K Dec 3 17:53 org.swtk.common.core  
 drwxrwxr-x 7 craigtrim craigtrim 4.0K Dec 3 17:53 org.swtk.common.data  
 drwxrwxr-x 5 craigtrim craigtrim 4.0K Dec 3 17:53 org.swtk.common.mysql  
 -rw-rw-r-- 1 craigtrim craigtrim  0 Dec 3 17:53 README.md    



References

  1. https://help.github.com/articles/setting-your-username-in-git/
    1. Setting your username in Git
  2. [YouTube] How to Install and Configure Git & Repositorys on GitHub
  3. Cloning a Remote Repository using Git

No comments:

Post a Comment