DEV Community

Vivian
Vivian

Posted on

OSD600 - Using Git Remote And Git Merge For Collaboration

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.

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
  • If the file is missing, or can't be parsed as JSON, the ssg will exit with an appropriate error message. 9f82ad
  • 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
  • Update README.md. e5e825

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.gitcommand to add his repo as a remote in my local repo.
image

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

3. Reviewing and testing Dustin's work on 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
Enter fullscreen mode Exit fullscreen mode

Then, I created a tracking branch which is used to review and test the work.

git checkout -b tuanthanh2067-issue-21 tuanthanh2067/issue-21
Enter fullscreen mode Exit fullscreen mode

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!

Top comments (0)