

Git Simplified: Working with Remote Repositories
source link: https://dev.to/ruppysuppy/git-simplified-working-with-remote-repositories-106f
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.


Git Simplified: Working with Remote Repositories
Jul 4
・3 min read
Git Mastery (2 Part Series)
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.
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
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.
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.
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 😉
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
Want to work together? Contact me on Upwork
Want to see what I am working on? Check out my GitHub
I am a freelancer who will start off as a Digital Nomad in mid-2022. Want to catch the journey? Follow me on Instagram
Follow my blogs for weekly new tidbits on Dev
Connect to me on:
Recommend
-
9
Introduction The GitPython project allows you to work in Python with Git repositories. In this guide we'll look at some basic operations like: Initializing a repo
-
11
How to Merge in Git: Remote and Local Git Repositories Tutorial Jeff Brown Updated: 3/8/2021 In my previous article “
-
5
Situation We were having multiple projects in a folder and all pointing to its own remote git repo. we thought of making our parent folder also available on GitHub, so that all projects are available at one place. We went ahead with...
-
8
Git: Automatic recovery from remote repositories? advertisements One irritating thing I find about using command line Git is having to manuall...
-
9
Rationale Multi-repository development, while providing architectural advantages (reduced scope of libraries, faster development cycles, …), are often painful for developers, especially when the number of modules being involv...
-
13
Introducing git ship, a simplified git flow workflowApril 07, 2018 · 7 min read ·
-
7
Migrate git repositories | Posted: 2012-10-01 | ~100wrds (~1min) | Last updated: 2020-03-11 ...
-
9
GIT Mirrors of my SVN Repositories To whom it may concern: as a first step to move away from SVN and towards GIT for all my cod...
-
8
best way to synchronize two remote repositories in GIT advertisements We have one internal remote repository in...
-
9
Setup multiple git identities & git user informations /!\ Be very carrefull in your setup : any misconfiguration make all the git config to fail silently ! Go trought this guide step by step and it s...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK