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.
Table of Contents
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.
That’s is all. The token is going to be your new password!
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
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.
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
The username and password will be saved in the file
~/.git-credentials. in the format
You can check that with the command
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.
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
Some of the related articles I have written and you might like reading them.
That is all. With these simple steps, you learn how to use Git in Ubuntu.