Home DevOPs Git Commands

Git Commands

by Editorial Staff

Git is a distributed version control system that helps developers collaborate on projects of any
scale.
Linus Torvalds, the developer of the Linux kernel, created Git in 2005 to help control the Linux
kernel’s development.

What is a Distributed Version Control System?

A distributed version control system is a system that helps you keep track of changes you’ve
made to files in your project.
This change history lives on your local machine and lets you revert to a previous version of your
project with ease in case something goes wrong.
Git makes collaboration easy. Everyone on the team can keep a full backup of the repositories
they’re working on on their local machine. Then, thanks to an external server like Bit Bucket,
GitHub or GitLab, they can safely store the repository in a single place.
This way, different members of the team can copy it locally and everyone has a clear overview
of all changes made by the whole team.
Git has many different commands you can use. And I’ve found that these fifty are the ones I use
the most often (and are therefore the most helpful to remember).

Getting Started – Installing Git

Installing Git

Before you start using Git, you have to make it available on your computer. Even if it’s already
installed, it’s probably a good idea to update to the latest version. You can either install it as a
package or via another installer, or download the source code and compile it yourself.

Note:

This document was written using Git version 2. Since Git is quite excellent at preserving
backwards compatibility, any recent version should work just fine. Though most of the
commands we use should work even in ancient versions of Git, some of them might not
or might act slightly differently.

Installing on Linux

If you want to install the basic Git tools on Linux via a binary installer, you can generally
do so through the package management tool that comes with your distribution. If you’re on

Fedora (or any closely-related RPM-based distribution, such as RHEL or CentOS),

you can use dnf:

$ sudo dnf install git-all

If you’re on a Debian-based distribution, such as Ubuntu, try apt:

$ sudo apt install git-all
Some times you will face this type of issues while installing git on linux
Platforms.
root@vmlinux:~# sudo apt install git-all
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package git-all
Try this and then install
root@vmlinux:~# sudo apt update
Hit:1 http://azure.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://azure.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7
kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu bionic-backports InRelease [83.3
kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7
kB]
..
Get:20 http://azure.archive.ubuntu.com/ubuntu bionic-security/universe amd64
Packages [1232 kB]
Get:21 http://azure.archive.ubuntu.com/ubuntu bionic-security/universe
Translation-en [283 kB]
..-security/multiverse Translation-en [3836 B]
Fetched 23.5 MB in 5s (4639 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
root@vmlinux:~# sudo apt install git-all
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
linux-headers-4.15.0-193
..

libtypes-serialiser-perl liburi-perl libvariable-magic-perl libwayland-
client0 libwayland-cursor0 libwayland-egl1

libwebp6 libwww-perl libwww-robotrules-perl libx11-xcb1 libxaw7 libxcb-
dri2-0 libxcb-dri3-0 libxcb-glx0

libxcb-present0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1
libxcomposite1 libxcursor1 libxdamage1
libxfixes3 libxft2 libxi6 libxinerama1 libxkbcommon0 libxmu6 libxpm4
libxrandr2 libxrender1 libxshmfence1 libxss1
libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 libyaml-libyaml-perl
libyaml-perl m17n-db perl-openssl-defaults

poppler-data runit ssl-cert tcl tcl8.6 tk tk8.6 ubuntu-mono x11-common x11-
utils xbitmaps xterm
0 upgraded, 275 newly installed, 0 to remove and 1 not upgraded.
Need to get 108 MB of archives.
After this operation, 657 MB of additional disk space will be used.
Do you want to continue? [Y/n] C
Continue with Y
....
Setting up libsoup-gnome2.4-1:amd64 (2.62.1-1ubuntu0.4) ...
Setting up librest-0.7-0:amd64 (0.8.0-2) ...
Setting up libgtk-3-0:amd64 (3.22.30-1ubuntu4) ...
Setting up libgtk-3-bin (3.22.30-1ubuntu4) ...
Setting up emacs25 (25.2+1-6) ...
update-alternatives: using /usr/bin/emacs25-x to provide /usr/bin/emacs
(emacs) in auto mode
Install emacsen-common for emacs25
emacsen-common: Handling install of emacsen flavor emacs25
Install git for emacs25
install/git: Handling install of emacsen flavor emacs25
install/git: Byte-compiling for emacs25
+ emacs25 -batch -q -no-site-file -f batch-byte-compile git.el git-blame.el
Setting up emacs (47.0) ...
Setting up git-el (1:2.17.1-1ubuntu0.12) ...
Install git for emacs
Install git for emacs25
install/git: Handling install of emacsen flavor emacs25
install/git: Byte-compiling for emacs25
+ emacs25 -batch -q -no-site-file -f batch-byte-compile git.el git-blame.el
Setting up git-all (1:2.17.1-1ubuntu0.12) ...
Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...

Its completed, you verify with below commands

root@vmlinux:~# git version
git version 2.17.1
root@vmlinux:~# git --version
git version 2.17.1
root@vmlinux:~#

For more options, there are instructions for installing on several different Unix distributions on
the Git website, at https://git-scm.com/download/linux.

You may also like

Leave a Comment

Contact US

Phone Number

+91 XXXXX XXXXX

Location

2nd floor, # 85, SGR Dental College Rd, Marathahalli, Bengaluru, Karnataka 560037

Email Address

contact@dbacentre.com

    dbacentre.com is a website that publishes practical and helpful out-of-the-box articles for aspirants like you and me. In addition, we seek to present exceptional, remarkable tutorials and tips that modern cloud professionals will appreciate.

     

    Subscribe now

    Edtior's Picks

    by mukilan
    Sql
    by mukilan

    ©2023 Mr DBA CENTRE. All Right Reserved. Designed and Developed by Begintech.in