DEV Community

Cover image for Git Simplified: Working with Remote Repositories
Tapajyoti Bose
Tapajyoti Bose

Posted on • Edited on

12 2

Git Simplified: Working with Remote Repositories

This article is a continuation of the last blog 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.

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

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

git clone <clone link>
Enter fullscreen mode Exit fullscreen mode

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

Clone Link

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>
Enter fullscreen mode Exit fullscreen mode

The convention is to use "upstream" for the upstream remote name

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

Yay

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>
Enter fullscreen mode Exit fullscreen mode

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

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>
Enter fullscreen mode Exit fullscreen mode

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

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!

Thanks for reading

Need a Top Rated Software Development Freelancer to chop away your development woes? Contact me on Upwork

Want to see what I am working on? Check out my Personal Website and GitHub

Want to connect? Reach out to me on LinkedIn

Follow my blogs for bi-weekly new Tidbits on Medium

FAQ

These are a few commonly asked questions I get. So, I hope this FAQ section solves your issues.

  1. I am a beginner, how should I learn Front-End Web Dev?
    Look into the following articles:

    1. Front End Buzz words
    2. Front End Development Roadmap
    3. Front End Project Ideas
    4. Transition from a Beginner to an Intermediate Frontend Developer
  2. Would you mentor me?

    Sorry, I am already under a lot of workload and would not have the time to mentor anyone.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay