How to Install Git on Debian 8.6

To Install Git On Debian 8.6

Git is an open-source revision control system which was developed by Linus Torvalds. It has abundant features and posses an intuitive syntax. It tracks any changes made on computer files and co-ordinates the work on those files among multiple people. This tutorial will help you with the installation of Git on Debian 8.6

Installing Git

The initial step for installing Git on Debian is to open the repo file and add the repository. Use the following command for the following command.

root@linuxhelp:~# nano /etc/apt/sources.list
deb http://ftp.debian.org/debian/ stable main contrib non-free
deb http://ftp.de.debian.org/debian jessie main

Once it is added, update the newly added repository in the system by invoking the following command.

root@linuxhelp:~# apt-get update
Hit http://ftp.debian.org jessie-updates InRelease                             
Ign http://ftp.de.debian.org jessie InRelease                                  
Ign http://ftp.debian.org stable InRelease                                     
Get:1 http://ftp.de.debian.org jessie Release.gpg [2,373 B]
Hit http://security.debian.org jessie/updates InRelease                        
Hit http://ftp.debian.org jessie-updates/main Sources
Get:2 http://ftp.de.debian.org jessie Release [148 kB]  
.
.
.
Get:11 http://ftp.debian.org stable/contrib Translation-en [38.5 kB]           
Get:12 http://ftp.debian.org stable/main Translation-en [4,582 kB]             
Get:13 http://ftp.de.debian.org jessie/main Translation-en [4,582 kB]          
Get:14 http://ftp.debian.org stable/non-free Translation-en [72.1 kB]          
Fetched 23.3 MB in 2min 36s (149 kB/s)                                         
Reading package lists... Done

Now is the time to install the Git package. Do it with the following command.

root@linuxhelp:~# apt-get install git -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  git-man liberror-perl rsync
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-cvs git-mediawiki git-svn openssh-server
The following NEW packages will be installed:
  git git-man liberror-perl rsync
0 upgraded, 4 newly installed, 0 to remove and 130 not upgraded.
Need to get 4,942 kB of archives.
After this operation, 24.3 MB of additional disk space will be used.
Get:1 http://ftp.debian.org/debian/ stable/main liberror-perl all 0.17-1.1 [22.4 kB]
.
.
.
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (215-17+deb8u5) ...
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:2.1.4-2.1+deb8u2) ...
Setting up git (1:2.1.4-2.1+deb8u2) ...
Setting up rsync (3.1.1-3) ...
Processing triggers for systemd (215-17+deb8u5) ...


Git has been installed, access it by using the following command.

root@linuxhelp:~# git
usage: git [--version] [--help] [-C < path> ] [-c name=value]
           [--exec-path[=< path> ]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=< path> ] [--work-tree=< path> ] [--namespace=< name> ]
           < command>  [< args> ]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
.
.
.
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

' git help -a'  and ' git help -g'  lists available subcommands and some
concept guides. See ' git help < command> '  or ' git help < concept> ' 
to read about a specific subcommand or concept.

If you want to remove Git from your system, use the following command.

root@linuxhelp:~# apt-get remove git -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  git-man liberror-perl rsync
Use ' apt-get autoremove'  to remove them.
The following packages will be REMOVED:
  git
0 upgraded, 0 newly installed, 1 to remove and 130 not upgraded.
After this operation, 22.2 MB disk space will be freed.
(Reading database ... 137580 files and directories currently installed.)
Removing git (1:2.1.4-2.1+deb8u2) ...


Tag : debian Git
FAQ
Q
How do I push my changes?
A
Use the following command:
git push
git push origin branch-name
Q
where to find the gitlab exported project path?
A
Gitlab will stores the exported project in this location /var/opt/gitlab/gitlab-rails/shared/tmp/project_exports/
Q
How do I change my last commit message?
A
Run the following command:
#git commit --amend --only
Or, without staged changes:
#git commit --amend
Q
How do I commit a file?
A
Run the following command:
#git add file.js # stage the file
#git commit # commit the file
Q
How do I get a list of files that have changed since a commit?
A
After getting the appropriate hash from a command like a git log

git diff --name-only cda409f..