How to install git & configure git with github on Ubuntu 20.04

Git is a open-source packages & distributed version control system.It provides to handle everything from small to very large projects with speed and efficiency.Using git,we can push & pull all the files & folders from github.Github is a platform where we can create repository & upload the files & folder from local machine to github repo.

Update the System.

apt-get update

Install git on ubuntu.

apt-get install git

Configuring GitHub

Provide the user-name of Github.

git config --global user.name "user_name"

Provide the email-id of Github.

git config --global user.email "email_id"

Create a local repository.Provide the folder name.

git init example

Here is the command output.

Initialized empty Git repository in /home/ubuntu/example/.git/

Go to new created folder.

cd example

Create a file to describe the repository.Provide the content.

vim test

Adding repository files to an index.

git add test 
or
git add file-name

Committing changes made to the index.

git commit -m "message"

Login to Github.

 

Fig 1

  • Click on New.

 

Fig 2

 

  • Provide the repository name.
  • Select public or private option for repository.
  • Click on Create Repository.

 

Fig. 3

 

Connect to the repository on GitHub.

git remote add origin https://github.com/user_name/example.git

Push files in a local repository to GitHub repository.

git push origin master

Provide the user-name & Password of Github.

Here is the command output.

 

root@ip172-23-21-13:/home/ubuntu/example#git git push origin master
Username for 'https://github.com' : user-name
Password for 'https://[email protected]' :

 

 

Leave a Reply