OSD600 - Using Git Remote And Git Merge For Collaboration
Tags: opensource, gitmerge, gitremote
Published: 2021-10-08 21:27:18

## 1. Lab4 requirements
In lab4, I have another chance to contribute to my classmate's repo. This time I am going to add support for config files to [Dustin's repo](https://github.com/tuanthanh2067/cv-ssg).

Below is some changes, I've applied to his repo:
* Set up the `-c` or `--config` which will accept a file path to a JSON config file. [588185](https://github.com/tuanthanh2067/cv-ssg/pull/22/commits/5881851750fec169b8900f4f3a36fd8f767efbb1)
* If the file is missing, or can't be parsed as JSON, the ssg will exit with an appropriate error message. [9f82ad](https://github.com/tuanthanh2067/cv-ssg/pull/22/commits/9f82ade3f38a2243ad25669ab08f25bbdc19d71b)
* If the `-c` or `--config` option is provided, the app will ignore all other options. The app also ignores any options in the config file it doesn't recognize. The default value will be used, if an option is not specified in the provided config file. [90d788](https://github.com/tuanthanh2067/cv-ssg/pull/22/commits/90d788cbb686cab1df469d52edd1e309d7e54aa9)
* Update README.md. [e5e825](https://github.com/tuanthanh2067/cv-ssg/pull/22/commits/e5e82519b00e0fb23a12e1337fa64641f1c90de0)

## 2. Contributing process

First of all, I forked Dustin's repo to my account then I used `git clone https://github.com/hlavu/cv-ssg.git` command to clone the forked repo to my desktop so that I can work on it locally.

Next, I used `git remote add upstream https://github.com/tuanthanh2067/cv-ssg.git`command to add his repo as a remote in my local repo. 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gtpfbmmrwyqi6s19113k.png)

To avoid the situation when my local repo is outdated, I run `git pull upstream master` command to download and merge all changes in the upstream repo. 

After that, I created, switched to the `config-support` branch by using `git checkout -b config-support` and started reading through Dustin's code to understand the logic and determine his style.

Luckily, Dustin's logic is very clear, the code is neat and readable so it took me about 5 minutes to start applying new feature. 

When I submitted the PR, Dustin requested me to remove some redundant codes and add some return statements, then the PR got merged.

The detail of modifications were specified in [PR #22](https://github.com/tuanthanh2067/cv-ssg/pull/22)

## 3. Reviewing and testing Dustin's work on [my ssg](https://github.com/hlavu/my-ssg) using `git remote`
After Dustin pulled a request which is ready for reviewing, I added his forked `my-ssg` as a remote to my local repo. To download all changes but not merge them into my local repo, I used `git fetch` command.

```
git remote add tuanthanh2067 https://github.com/tuanthanh2067/my-ssg.git
git fetch tuanthanh2067
```
Then, I created a tracking branch which is used to review and test the work.
```
git checkout -b tuanthanh2067-issue-21 tuanthanh2067/issue-21
```
If any problem is detected, I will leave a comment in the pull request and ask for modification. Fetching and testing will be repeated until the code does not contain any problem. 

## 4. Overall
`git remote` is a helpful command since it facilitates the connection between a user to other's repos so they can collaborate on a project. This lab is an enjoyable experience. Also, thanks Dustin so much for your contribution.

Happy coding!