Git Simplified: Working with Remote Repositories
Tags: git, beginners, productivity, github
Published: 2021-07-04 04:37:39

This article is a continuation of the [last blog](https://dev.to/ruppysuppy/git-fundamentals-concepts-commands-simplified-2k4j) on `git` basics. You are highly encouraged to check it out before reading this article.

Often working on a large project, you will be collaborating with large teams to bring the project to life. `Git` helps to streamline this process making it easier for developers to collaborate on `git`-based platforms such as [GitHub](https://github.com/ruppysuppy).

In this article, we will be going through how to contribute to repositories hosted on **GitHub** (you can use the same steps to work repositories hosted on other sites like **GitLab** as well).

# Setup The Repository Locally

If you are contributing to a repository _you don't have write access_ to, you must **Fork** the repository as the first step. 

![Fork Repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nvfl4gad1k10999gtltg.png)

Now you have a personal copy of the repository. Clone the repository using the command:

```
git clone <clone link>
```

You can find the clone link in the clone tab of the **forked repository**

![Clone Link](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3mmpzrwleruz2h8a8fr5.png)

**NOTE:** If you own the repository or have _write access_ you should copy the clone link from the actual repository as making a **fork** is unnecessary.

If you do not have _write access_, there is yet another additional step. Go into the cloned repository and add an **upstream remote** (fancy name for the source repository). 

```
git remote add <upstream remote name> <source repository clone link>
```

The convention is to use "upstream" for the _upstream remote_ name

Now you have the remote repository set up in your local machine.

![Yay](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgq7bus1mxrfn502ofq4.gif)

# Updating The Local Repository 

If you are working with a group of people, you would be required to fetch the changes made by others. To get the updates, the command is:

```
git pull <remote repository> <branch name>
```

The repository will be "origin" if you have _write access_ else _the upstream remote name you used_ while adding the _upstream remote_ in the previous step.

![Pull Changes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70qpu5mf3xcnqlnjua6u.PNG)

# Updating The Remote Repository

After making the required changes, you would like to push the changes to the remote repository for others to access it. To push the changes to the origin repository use:

```
git push origin <branch name>
```

Now the origin repository contains the changes you made. If you don't have _write access_, you will need to create a **Pull Request** in the source repository where your changes will be reviewed and merged by the owners or collaborators of the repository.

# Conclusion

Congratulation on reading the entire article! Don't forget the pat on your back; you deserve this 😉

![Pat on the back](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/klwbbt8yahwcwb24g5ji.gif)

Now you have advanced `git` in your arsenal. It's time for you, my disciple, to barge forward and create and contribute to awesome repositories!

Finding **personal finance** too intimidating? Checkout my **Instagram** to become a [**Dollar Ninja**](https://www.instagram.com/the.dollar.ninja/)

# Thanks for reading

Want to work together? Contact me on [Upwork](https://www.upwork.com/o/profiles/users/~01c12e516ee1d35044/)

Want to see what I am working on? Check out my [GitHub](https://github.com/ruppysuppy)

I am a freelancer who will start off as a Digital Nomad in mid-2022. Want to catch the journey? Follow me on [Instagram](https://www.instagram.com/tapajyotib/)

Follow my blogs for weekly new tidbits on [Dev](https://dev.to/ruppysuppy)

Connect to me on:

-   [LinkedIn](https://www.linkedin.com/in/tapajyoti-bose-429a601a0)
-   [Portfolio](https://tapajyoti-bose.vercel.app)
-   [Upwork](https://www.upwork.com/o/profiles/users/~01c12e516ee1d35044/)
-   [GitHub](https://github.com/ruppysuppy)
-   [Instagram](https://www.instagram.com/tapajyotib/)