• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

How to use Git and GitHub in Ubuntu [Installation, Configuration]

Aniruddha Chaudhari/1002/0
gitLinux

Update: If you are trying to access Git with the password (as you were accessing it earlier), you will see the authentication error “fatal: Authentication failed”. Support for password authentication was removed on August 13, 2021. You have to use the personal Git access authentication token to use Git.

In this tutorial, I’m going to demonstrate the steps for setting up the Git and GitHub on Ubuntu for your project. With these simple steps, you can set up git on any Linux distro.

git tutorial

Let’s begin.

Table of Contents

  • Step1: Generate Personal Git Token
  • Step 2: Configue Local Git
  • Step 3: Clone Your GitHub Repo
  • Step 4: Setup Git Username and Password Credentials
  • Step 5: Set Origin URL

Step1: Generate Personal Git Token

GitHub is one of the most popular DevOps tools. There are many alternatives, though.

Follow the steps to generate a personal Git access token on GitHub.

  1. Log into GitHub with your username and password.
  2. In upper right corner, click on your name / avatar and select Settings.
  3. From left sidebar, select Developer settings
  4. Click on Personal access tokens and then Generate new token
  5. Add some description or name to the token and select the scope.
    • If you are only interested to access your repo, select only repo. With this you can perform basic repo actions like pull, push, clone, and commit.
  6. Now click Generate token
  7. Copy your personal git access token.

That’s is all. The token is going to be your new password!

Step 2: Configue Local Git

You don’t need to install anything to use Git on Ubuntu. By default, Ubuntu supports Git.

Set your git account locally on your Ubuntu (Linux OS) system. There are two basic configurations that you need to set i.e. name and email. Here are simple commands.

Important: In the below command, add your name and email inside brackets. First, two commands are to set up the name and email. With the third command, you can check if your configuration parameters are set properly.

git config --global user.name ""
git config --global user.email ""
git config -l

Step 3: Clone Your GitHub Repo

If you have a repo on GitHub, you can clone it.

git clone <git-repo-url>

You will be asked to enter the username and password. Provide a token as your password.

Step 4: Setup Git Username and Password Credentials

If you don’t set up or configure username and password, git will ask you to enter username and password every time you try to pull or push the code. This will be really frustrating.

If you want to avoid providing a username and password every time, you can just store that username and password.

Run the following command.

git config --global credential.helper store

Now when you try to connect to the remote repo, you will be asked for the username and password. This time your username and password will be saved so that you don’t need to provide a username and password again.

Note: This command saves the username and password in plain text format on your disk.

You can check the configuration in the file ~/.gitconfig.

vi ~/.gitconfig

The username and password will be saved in the file ~/.git-credentials. in the format

https://git-user:[email protected]

You can check that with the command

vi ~/.git-credentials

You can also opt for cache to store the username and password instead of disk.

git config --global credential.helper cache

This is more secure than storing credentials on a disk.

Step 5: Set Origin URL

This is an alternative step to step 4.

You can also set the origin URL for your remote git access.

git remote set-url origin <new_git_repo_url_with_toekn>

The format for the new_git_repo_url_with_toekn is

https://<personal_git_acess_toekn>@<git_repo_url>

Some of the related articles I have written and you might like reading them.

  • Git Interview Questions
  • GitOps vs DevOps

That is all. With these simple steps, you learn how to use Git in Ubuntu.

gitlinux
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Leave a Reply Cancel reply

Git Tutorial

Git- Introduction

Git- What is Code Repository?

Git- About GitHub

Git- Installation

Git- Essential Git Commands

1. Configuring Git

2. Initializing Git

3. Git Clone

4. Git Checkout

5. Git Add

6. Git Status

7. Git Commit

8. Git Push

9. Git Merge without missing changes

10. Git Revert Commit

Git- Interview Questions

Git Setup

Git- Setup on Ubuntu

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard