# How to configure a Git repository using Linux CLI?

### Overview

This tutorial provides a general overview of how to set up a Git repository using the Linux command line. It introduces the essential Git operations and guides you through the process of creating a new or ongoing Git repository. This tutorial assumes that you have some familiarity with the command line

### Prerequisites

* Already created [GitHub account.](https://github.com/)&#x20;
* Ubuntu 20.04&#x20;
* SSH connected text editor&#x20;
* Internet connection&#x20;

### **Get Started**

**Step 1: Git Installation**&#x20;

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.&#x20;

Enter into root user.&#x20;

```
 $ sudo -i
```

Update your system with the following command:&#x20;

```
 $ sudo apt-get update 
```

Download and install git, using the following command:&#x20;

```
$ sudo apt-get install git 
```

Verify the installation by running the following command:&#x20;

```
$ sudo --version 
```

**Step 2: Git Proxy Configuration**&#x20;

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**&#x20;

Login to the official GitHub page and make a new repository.&#x20;

**Step 4: Basic Git Workflow**&#x20;

{% hint style="info" %}
**Note:** Kindly insert your own values in between <>, wherever given.&#x20;
{% endhint %}

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

```
$ mkdir <folder-name> 
```

Create a file in the recently made folder:&#x20;

```
$ cd < folder-name> 
```

```
$ nano <file-name>  
```

Initialize the git repository, by using the following command:&#x20;

```
$ 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:&#x20;

```
$ git status
```

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

```
$ git add .
```

{% hint style="info" %}
**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:&#x20;
{% endhint %}

```
$ git add <file name> 
```

You may check again the status of your files, by using `git status` command.  Save all the changes made to the working directory by using the following command takes everything in the staging area and makes a permanent snapshot of your repo’s current state.&#x20;

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

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

```
$ git remote add origin <remote-repo's URL>
```

Two arguments are required for the `git remote add` command:&#x20;

* A remote name, for instance, origin.&#x20;
* A remote URL address, like <https://github.com/user/repo.git>&#x20;

To push the latest changes to the central working directory, the following command is used:&#x20;

```
$ git push –u origin main
```

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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-configure-a-git-repository-using-linux-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
