Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions docs/gemstones/git/git_remote_add.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Adding a remote repository using git CLI
author: Wale Soyinka
contributors:
contributors: Ganna Zhyrnova
tags:
- GitHub
- git
Expand All @@ -11,7 +11,7 @@ tags:

## Introduction

This Gemstone illustrates how to add a specific remote repository, to an existing local clone of a FOSS project using the Git command-line interface.
This Gemstone illustrates how to add a specific remote repository to an existing local clone of a FOSS project using the Git command-line interface.
We'll use the repository of the Rocky Linux documentation project as our example FOSS project - `https://github.com/rocky-linux/documentation.git`

## Prerequisites
Expand All @@ -22,25 +22,22 @@ We'll use the repository of the Rocky Linux documentation project as our example

## Procedure

1. Open a terminal and change your working directory to the folder containing your
local clone of the project.
1. Open a terminal and change your working directory to the folder containing your local clone of the project.
For example if you cloned the github repo to ~/path/to/your/rl-documentation-clone, type
```bash
cd ~/path/to/your/rl-documentation-clone
```
2. Before making any changes, list the remotes that you currently have configured. Type:
2. Before making any changes, list the remotes you have configured. Type:
```bash
git remote -vv
```
If this is a freshly cloned repo, you will likely see a lone remote named `origin` in your output.
3. Add the Rocky Linux Documentation Repository
(`https://github.com/rocky-linux/documentation.git`) as a new remote to your local repository. Here we'll assign upstream as the name for this particular remote. Type:
3. Add the Rocky Linux Documentation Repository (`https://github.com/rocky-linux/documentation.git`) as a new remote to your local repository. Here, we'll assign upstream as the name for this particular remote. Type:

```bash
git remote add upstream https://github.com/rocky-linux/documentation.git
```
4. To further emphasis that the names assigned to remote repositories are arbitrary,
create another remote named rocky-docs that points to the same repo, by running:
4. To further emphasize that the names assigned to remote repositories are arbitrary, create another remote named rocky-docs that points to the same repo by running:
```bash
git remote add rocky-docs https://github.com/rocky-linux/documentation.git
```
Expand All @@ -49,23 +46,21 @@ We'll use the repository of the Rocky Linux documentation project as our example
git remote -v
```
You should see `upstream` listed along with its URL.
6. Optionally, before you start making any changes to your local repo, you can fetch
data from the Newly Added Remote.
6. Optionally, before you start making any changes to your local repo, you can fetch data from the Newly Added Remote.
Fetch branches and commits from the newly added remote by running:
```bash
git fetch upstream
```

## Additional Notes

- *Origin*: This is the default name Git gives to the remote repository from which you
cloned. It's like a nickname for the repository URL. When you clone a repository, this remote repository is automatically set as "origin" in your local Git configuration. The name is arbitrary but conventional.
- *Origin*: This is the default name Git gives to the remote repository from which you cloned. It's like a nickname for the repository URL. When you clone a repository, this remote repository is automatically set as "origin" in your local Git configuration. The name is arbitrary but conventional.

- *Upstream*: This often refers to the original repository when you've forked a project.
In open-source projects, if you fork a repository to make changes, the forked repository is your "origin", and the original repository is typically referred to as "upstream". The name is arbitrary but conventional.

This subtle distinction between the uses/assignment of origin and remote is crucial for contributing back to the original project through pull requests.
This subtle distinction between the uses/assignment of origin and remote is crucial for contributing to the original project through pull requests.

## Conclusion

Using a descriptive name and adding a specific remote repository to a local clone of a FOSS project is easy with the git CLI utility. This allows you to sync with and contribute to various repositories effectively.
The git CLI utility makes it easy to use a descriptive name and add a specific remote repository to a local clone of a FOSS project. This allows you to sync with and contribute to various repositories effectively.