{"id":709,"date":"2016-12-09T00:00:00","date_gmt":"2016-12-09T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/how-to-install-git-on-ubuntu\/"},"modified":"2026-03-10T09:31:26","modified_gmt":"2026-03-10T09:31:26","slug":"how-to-install-git-on-ubuntu","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-install-git-on-ubuntu","title":{"rendered":"How to install Git on Ubuntu using apt and GitHub"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Modern software development requires a lot of work to be successful. One of the most important steps is choosing a distributed version control system.<\/p><p>Such systems help you keep track of every code change and revert previous stages if needed. One of the most popular version control systems is Git.<\/p><p>In this tutorial, we&rsquo;ll show two simple ways how to install Git on Ubuntu and how to configure it. <\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Git-Cheat-Sheet-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download complete GIT cheat sheet<\/a><\/p><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-git-on-ubuntu\">How to Install Git on Ubuntu<\/h2><p>Git installation on an Ubuntu system requires three essential objects:<\/p><ul class=\"wp-block-list\">\n<li><strong>Ubuntu version<\/strong> &ndash; this tutorial covers Ubuntu <strong>22.04<\/strong>. Ensure that the latest version is running on your computer or a <a href=\"\/ca\/vps-hosting\">hosted virtual server<\/a> (VPS).<\/li>\n\n\n\n<li><strong>Sudo privileges<\/strong> &ndash; an account with sudo privileges is required to install Git. It can be a root account or a separate user account with administrator privileges.<\/li>\n\n\n\n<li><strong>Access to the terminal<\/strong> &ndash; Git installation will include commands that must be entered into the terminal window.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-step-1-install-git-on-ubuntu\">Step 1 &ndash; Install Git on Ubuntu<\/h3><p>There are two ways to install Git on Ubuntu. We&rsquo;ll break them down one by one, but you can choose which one works best for you. It&rsquo;s worth noting that both require access to the terminal.<\/p><p><strong>Installing Git With APT<\/strong><\/p><p>Ubuntu already has Git in the default repository. It can be easily installed with the help of the APT package management tool:<\/p><ol class=\"wp-block-list\">\n<li>Update the repository by running the following command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt-get update<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Install Git with this command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt install git<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>When asked for permission to install Git, type <strong>Y<\/strong>, and press <strong>Enter<\/strong>.<\/li>\n<\/ol><p>Keep in mind that the Git version in the APT package manager might differ from the recent version found on the <a href=\"https:\/\/git-scm.com\/downloads\" target=\"_blank\" rel=\"noopener\">GitHub source website<\/a>. You can check the available versions using this command:<\/p><pre class=\"wp-block-preformatted\">apt-cache policy git<\/pre><p>Here&rsquo;s an example of what the output would look like:<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/Command-prompt-window-showcasing-a-command-used-to-check-which-Git-version-will-be-installed-with-the-APT-package-manager-on-Ubuntu-20.04..png\"><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"222\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/Command-prompt-window-showcasing-a-command-used-to-check-which-Git-version-will-be-installed-with-the-APT-package-manager-on-Ubuntu-20.04..png\" alt=\"Command prompt window showcasing a command used to check which Git version will be installed with the APT package manager on Ubuntu 20.04\" class=\"wp-image-66020\"  sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/a><\/figure><\/div><p>There are two available versions &ndash; <strong>2.17.1 <\/strong>and <strong>2.17.0<\/strong>. The candidate version shows which version will be installed.<\/p><p>Alternatively, use this command after installing Git to check the version:<\/p><pre class=\"wp-block-preformatted\">git --version<\/pre><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p><strong>Installing Git from GitHub<\/strong><\/p><p>We recommend proceeding with the GitHub installation method if you want to install a different version of Git:<\/p><ol class=\"wp-block-list\">\n<li>Update the repository by running the following command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt-get update<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Install all the necessary GitHub packages using this command. Once the confirmation message appears, choose Y.<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Visit the <a href=\"https:\/\/git-scm.com\/download\/linux\" target=\"_blank\" rel=\"noopener\">Git for Linux download page<\/a>, right-click on the latest stable version, and copy the link. In our case, it&rsquo;s the <strong>2.36.1<\/strong> version.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/The-download-page-for-the-latest-version-of-Git.-The-red-border-indicates-the-download-URL-for-Git-2.36.1-version..png\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"120\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/The-download-page-for-the-latest-version-of-Git.-The-red-border-indicates-the-download-URL-for-Git-2.36.1-version..png\" alt=\"The download page for the latest version of Git. The red border indicates the download URL for Git 2.36.1 version\" class=\"wp-image-66022\"  sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/a><\/figure><\/div><ol start=\"4\" class=\"wp-block-list\">\n<li>Go back to the terminal and use the following command with the copied link:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">wget https:\/\/www.kernel.org\/pub\/software\/scm\/git\/git-2.36.1.tar.gz<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>To extract the file, <a href=\"\/ca\/tutorials\/linux-tar-command-with-examples\">run the tar command<\/a>:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">tar -zxf git-2.36.1.tar.gz<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Once the process is finished, head to the extracted directory:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">cd git-2.36.1<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Install Git globally by running this command:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">make prefix=\/usr install install-doc install-html install-info<\/pre><ol start=\"8\" class=\"wp-block-list\">\n<li>To verify the installation, use the following command prompt:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">git &ndash;-version<\/pre><p>If a Git version number appears, that means the installation was successful.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/A-command-to-check-the-Git-version..png\"><img loading=\"lazy\" decoding=\"async\" width=\"443\" height=\"65\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/A-command-to-check-the-Git-version..png\" alt=\"A command to check the Git version\" class=\"wp-image-66026\"  sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><\/figure><\/div><p><div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p> The previous method will install Git globally. If a local installation is needed, refer to the INSTALL file located in the archive for instructions.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-step-2-configure-the-git-account\">Step 2 &ndash; Configure the Git Account<\/h3><p>Once Git is installed, you will need to configure it with the Git config command.<\/p><ol class=\"wp-block-list\">\n<li>Specify your GitHub username on the terminal:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">git config --global user.name \"user_name\"<\/pre><p>Replace the <strong>&ldquo;user_name&rdquo;<\/strong> argument with an actual username, quotation marks included.<\/p><ol start=\"2\" class=\"wp-block-list\">\n<li>Specify the email address:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">git config --global user.email \"email@myawesomedomain.tld\"<\/pre><p>Make sure to replace <strong>&ldquo;email@myawesomedomain.tld&rdquo;<\/strong> with an actual email address, quotation marks included.<\/p><ol start=\"3\" class=\"wp-block-list\">\n<li>Verify the changes:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">git config --list<\/pre><div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/Git-config-command-to-set-configuration-settings-like-username-and-email.-An-alternative-way-would-be-to-open-Gitconfig-file-and-make-the-configuration-changes-manually.png\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"103\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2016\/12\/Git-config-command-to-set-configuration-settings-like-username-and-email.-An-alternative-way-would-be-to-open-Gitconfig-file-and-make-the-configuration-changes-manually.png\" alt=\"Git config command to set configuration settings like username and email. An alternative way would be to open Gitconfig file and make the configuration changes manually.\" class=\"wp-image-71549\"  sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/a><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Git is one of the world&rsquo;s most popular distributed version control systems. This free tool offers many valuable features and allows developers to perform any code changes with the ability to revert the changes if needed.<\/p><p>This tutorial covered how to install Git on Ubuntu via APT or GitHub. You also learned how to configure Git using your username and email address.<\/p><p>If you have any further insights or questions, leave them in the comments section below.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-full\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-web-hosting\" href=\"\/ca\/web-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/11\/Web-hosting_in-text-banner.png\" alt=\"Hostinger web hosting banner\" class=\"wp-image-98604\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-install-git-on-ubuntu-faq\">How To Install Git on Ubuntu FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1666082529681\"><h3 class=\"schema-faq-question\">How to Check if Git Is Already Installed?<\/h3> <p class=\"schema-faq-answer\">The easiest way to check if Git is installed is to run the <strong>git &ndash;version <\/strong>command, which will display the current version of Git.<br><br>Another option is to run <a href=\"\/ca\/tutorials\/basic-git-commands\">Git commands<\/a> like <strong>git build<\/strong>. If an error message such as<strong> &ldquo;git: command not found&rdquo; <\/strong>appears, it means that Git is not installed on the system. &nbsp;<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1666082544332\"><h3 class=\"schema-faq-question\">What Is the Default Git Install Location on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">Users can install Git either <strong>globally<\/strong> or <strong>locally<\/strong>. Git will be installed under the <strong>\/usr\/bin\/git <\/strong>directory if you&rsquo;re going with the global method. This can always be double-checked using the<strong> whereis git <\/strong>command, showing the exact Git installation directory.<br><br>However, if users use the local installation method, Git will only work on that particular directory. For example, if a user installs Git on the<strong> \/home\/username<\/strong> directory, they will need to navigate to this directory to use Git.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Modern software development requires a lot of work to be successful. One of the most important steps is choosing a distributed version control system. Such systems help you keep track of every code change and revert previous stages if needed. One of the most popular version control systems is Git. In this tutorial, we&rsquo;ll show [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-install-git-on-ubuntu\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":28,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Install Git on Ubuntu 22.04","rank_math_description":"Follow along to learn how to install Git on Ubuntu server using APT and GitHub as well as how to configure your Git account.","rank_math_focus_keyword":"install git ubuntu","footnotes":""},"categories":[22701,22699],"tags":[],"class_list":["post-709","post","type-post","status-publish","format-standard","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-instalar-git-no-ubuntu","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/instalar-git-en-ubuntu","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-install-git-ubuntu","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/instalar-git-en-ubuntu","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/joomla-vs-wordpress-cms-utilizar-16","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/instalar-git-en-ubuntu","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-instalar-git-no-ubuntu","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-git-on-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-git-on-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=709"}],"version-history":[{"count":26,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/709\/revisions"}],"predecessor-version":[{"id":140137,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/709\/revisions\/140137"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}