How to install Git in ubuntu 18.04LTS and start working

Github+ Ubuntu

Introduction

Git is a distributed revision control system with an emphasis on speed, data integrity, and support for distributed, non-linear workflows. Every Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.

GitHub is a Web-based Git repository hosting service, which offers all of the distributed revision control. Unlike Git, which is strictly a command-line tool, GitHub provides a Web-based graphical interface. GitHub is used for ‘version control’. This means that GitHub is used for software development projects when more than a person(or a group) is working on it.

For installation follow the steps for ubuntu 18.04 LTS (or any other linux based os) :

INSTALLING GIT:

Step 1: Open the Terminal (Press Ctrl+Alt+T from keyboard )and type

sudo apt-get install git

(after pressing enter after this command in terminal ,it will say to enter sudo password for this just enter the same password when you turn on the computer and press enter , while entering the password you can’t see the password that what you typed in the screen , this is for security purpose. Everytime after opening of terminal when anyone operates any sudo operation everytime password will be asked)

Step 2: Goto www.github.com and sign into your account. If you’re a new user, you can simply sign-up.

You’ll have a username from here. Let us say that it’s your_username

CONFIGURING GIT:

Step 1: Go back to the terminal and type this to configure git

git config –global user.name “your_username”

Step 2: Now type this to link your email too.

git config –global user.email “your_emailid”

USING GIT (If your account doesn’t have any repository):

Step 1: Go to your github account and create a repository with a name(lets say name of your project). We are creating a repository with the name myproject

Step 2: Make a folder with the name of your project and change your current directory to that directory.

mkdir myproject

cd myproject

Step 3: Now we want to initiate Git for this folder

git init

Step 4: Now we will set up the remote, which tells git where the repository is located.

git remote add origin https://github.com/your_username/myproject.git

We have now configured and installed git and, created and configured a repository. Now we can work and save our code files and other files related to the project in the project directory,

Step 5: To add this files that are saved locally at our computer inside the project directory we will type

git add .

This would transfer the file(s) in the list which we will later commit.

Step 6: Next, when we are finished adding the files, then we will have to commit adding.

git commit -m ‘your_message(like filename.c added to project)’

Step 7: Next, we need to push the commit that we just made on to the repository at github

git push origin master

It would automatically ask you for your username and password for github. After entering the details, go to github and refresh. The files would get added there.

Username for ‘ https://github.com ‘: your_username

Password for ‘ https://your_username@github.com ‘ : *******

Now from the next time you add ,delete, or update any file inside the project directory just follow the previous steps no 5 to 7 for make changes in the github repository.

USING GIT (If your account have already any repository):

Step 1: First he would have to download the whole repository .

git clone https://github.com/your_username/myproject.git

A folder named myproject gets downloaded with all the files in it. The necessary changes are made and then the file is similarly added, committed and pushed similarly as above.

Now open the project folder , open terminal from inside the project folder or after opening terminal just enter

cd ~/myproject.git

this command intends for change pf directory and ~/ signifies the exact file path where the project folder is located inside the computer.

Step 2: Now follow the previous steps from 3 to 7 .

--

--

GSoC’21 participant @CircuitVerse || ETCE Undergrad class of 2023 @Jadavpur University

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store