# Configure remote

## Configure remote repository

To be able to collaborate on any Git project, you need to know how to manage your remote repositories. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.&#x20;

{% hint style="info" %}
The word “remote” does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere!
{% endhint %}

### Showing Your Remotes <a href="#showing_your_remotes" id="showing_your_remotes"></a>

To see which remote servers you have configured, you can run the `git remote` command. It lists the shortnames of each remote handle you’ve specified. If you’ve cloned your repository, you should at least see `origin` — that is the default name Git gives to the server you cloned from:

```
git remote
```

{% hint style="info" %}
Note: If you do not get any output, it means no remote servers are configured!
{% endhint %}

You can also specify `-v`, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote, `v` stands for verbose:

```
git remote -v
```

## Create a repository on GitHub

You do not have an account, create a GitHub account and then from the homepage, create a `New` repository as highlighted in the below steps:

<div align="left"><figure><img src="/files/9hbSBw9f2EndyuB6lSNM" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/C8fhhGTsVLcXZGEE0kOR" alt=""><figcaption></figcaption></figure>

<div align="left"><figure><img src="/files/vVRkMMM2frg7bHKU8n8c" alt=""><figcaption></figcaption></figure></div>

<figure><img src="/files/Red4d4RzYd1Y0BtFCvsG" alt=""><figcaption></figcaption></figure>

## Push to GitHub repo

Using the commands which git is already showing, let us add and push our existing repository on to GitHub help with the below commands:

### Add reference to our repository&#x20;

```bash
git remote add origin https://github.com/ravirammysore/MyFirstRepo.git
```

### Push to GitHub

The `-u` switch makes the remote GitHub repo the default for your existing project (**'U' stands for upstream)**

```bash
git push -u origin master
```

{% hint style="info" %}
From next time we can simply specify `push` without specifying origin or master!
{% endhint %}

```
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (12/12), 1024 bytes | 1024.00 KiB/s, done.
Total 12 (delta 0), reused 0 (delta 0)

To https://github.com/ravirammysore/MyFirstRepo.git
 * [new branch]      master -> master
 
Branch 'master' set up to track remote branch 'master' from 'origin'.
```

```
git status

On branch master

Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
```

{% hint style="info" %}
We can also add the `-f` option in the above command to *force* the push. Sometimes our push operation may be rejected since there may be extra files present in GitHub (like readme.md file) which is not present in our local repository:

<pre><code><strong>git push -u -f origin master
</strong></code></pre>

{% endhint %}

## Verify the GitHub Push

To verify that the existing project was pushed to GitHub successfully, log into the GitHub website and browse the repository. All of the files from your existing project should be visible on GitHub’s.

So, refresh the browser and you should see the following:

<figure><img src="/files/x7fyOHlU12d77NPSXoaD" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/XRIttTS5Br6dHTvf3zzz" alt=""><figcaption></figcaption></figure>


---

# 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://raviram.gitbook.io/version-control/remote-repos/configure-remote.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.
