Working With Remotes in Git
Tags: opensource
Published: 2021-10-08 18:17:02

## Intro
This week in my open source development course, we learned about how to work with git remotes, such as how to fetch or pull and how to merge branches. I had the chance to work with two fellow classmates, [Irene Park](https://github.com/irenejoeunpark) whose repo I worked on and [Francesco Menghi](https://github.com/menghif) who worked on my repo. 

## Making Changes to Another Repo 
I was really excited to work on Irene's [repo](https://github.com/irenejoeunpark/ssgApplication) as although I have some experience working in Java, it has been a while since I last coded in the language. The feature I wanted to add was the option for a --config/-c flag in the command line so that rather than passing a long list of command line arguments, a user could pass a config file specifying all arguments. These were some of the main changes I made to her program

1. Added json-simple as a dependency to parse JSON files
2. Updated the code to check for the --config/-c flag in the command line. If the flag and config file exist, parse the file to get the input and output values. 
3. Updated the documentation 

I created an [issue](https://github.com/irenejoeunpark/ssgApplication/issues/18) and a draft [pull request](https://github.com/irenejoeunpark/ssgApplication/pull/19) which I updated gradually, so that Irene could see any significant changes I made along the way. Although the coding part was not too difficult, setting up the environment for Java in Visual Studio Code, adding the json-simple dependency, and creating the executable jar file were all new to me and took me a bit of time to figure out. I communicated my changes to Irene via Slack and my changes were successfully [merged](https://github.com/irenejoeunpark/ssgApplication/commit/78eedfbf667ef61cd1f98e68795c1e3633c40740) into her repo. 

## Accepting Changes to My Repo 
I also received an [issue](https://github.com/lyu4321/jellybean/issues/15) and [pull request](https://github.com/lyu4321/jellybean/pull/16) for my repo. I had a lot of great discussion with Francesco and he mentioned that he was "really seeing the benefit of code review now" after I tested his changes and made several suggestions. I was able to test his code by adding his repo as a remote to my local repo and creating a tracking branch. From there, I could pull any changes that he made and continue testing. After going back and forth a few times until all the problems were fixed, I [merged](https://github.com/lyu4321/jellybean/commit/32eed9a9e0fc01f6d5ed46a97cb26efc528a2a52) Francesco's branch with my main branch. I intended to merge it from the command line but accidentally did so through the GitHub interface. Thankfully, Francesco helped me out by creating another PR and I learned more about fetching and merging remotes through running the commands in the command line. 

## Working with Git
I found the process of using Git to be very straightforward and really useful, as it allowed me to collaborate with others across upstream/downstream repos. Although I have been using Git for a while, the concept of multiple remotes is new to me as I have never really worked with forked repos before so this was a great exercise to learn how to do so. I learned a lot about best practices for using remotes, which I will continue using in the future.