Setting up your remote Repo with Git 

This tutorial gives a general overview of how to configure a repository (repo) using the Linux command line interface. With an introduction to the essential git operations, this tutorial will guide you through setting up a Git repository for a new or ongoing project. 

This tutorial assumes that the reader is reasonably familiar with command-line interface. 

Pre-requisites: 

  1. Already created GitHub account. 
  2. Ubuntu 20.04 
  3. SSH connected text editor 
  4. Internet connection 

Step 1: Git Installation 

Git requires several dependencies to build on Linux, which can be fulfilled via apt, so we’ll use the same to install the latest version of git. 

Enter into root user. 

 $ sudo -i

Update your system with the update command: 

 $ sudo apt-get update 

Download and install git, using the following command: 

$ sudo apt-get install git 

Verify the installation by running the following command: 

$ sudo --version 

Step 2: Git Proxy Configuration 

Use the following commands to set up your Git login and email. Be sure to use your own name in place of DEMO. These credentials will be connected to any commits you make.

$ git config --global user.name "DEMO Username" 
$ git config --global user.name "DEMO Email" 

Step 3: Creating a new Repo 

On the official GitHub page, login yourself and make a new repository. 

Step 4: Basic Git Workflow 

Note: Kindly insert your own values in between <>, wherever given. 

Make a folder/ directory on the command line of your Linux machine, using the following command: 

$ mkdir <folder-name> 

Create a file in the recently made folder: 

$ cd < folder-name> 
$ nano <file-name>  

Initialize the git repository, by using the following command: 

$ git init

Let’s see the current position of our working directory and staging area. It will show the files and folders, ready to be added: 

$ git status

Use the add command to add the files to the staging area. It also prepares the staged items to be committed next. 

$ git add .

Note: The above command will add all the files and folders of that particular folder to the staging area. If you want any particular file to be staged, use the following command instead: 

$ git add <file name> 

You may again check the status of your files, by using git status command. 

Moving on, we need to save all the changes made to the working directory by using the commit command. 

commit command takes everything in the staging area and makes a permanent snapshot of your repo’s current state. 

$ git commit –m “<your-commit-message>” 

In the directory, where your repo is stored, add a new remote using git add remote command on the terminal.

$ git remote ad origin <remote-repo's URL>

Two arguments are required for the git remote add command: 

To push the latest changes to the central working directory, the following command is used: 

$ git push –u origin main

To clone or copy an existing repo in your new directory, the following command is used: 

$ git clone <path of repo, you want to clone>

 

 
 

 

 

Je li Vam ovaj odgovor pomogao? 1 Korisnici koji smatraju članak korisnim (2 Glasovi)