DEV Community

Andre Willomitzer
Andre Willomitzer

Posted on

git remote add <friend> <collaborate.git>

This week we practiced making contributions to a branch that we didn't create using git remote. In this week I worked on Gustavo Tavares' code Repo Link, and Mizuho Okimoto was working on my repository My Repo.

The feature we were meant to implement is using a configuration file to get the arguments for our tool. This is in addition to having the option to pass the arguments manually. However, the config file should override the values from the command line.

In order to do this, the logic included:

  • Checking if there's a JSON file.
  • Reading the file
  • Checking if it parsed correctly (no incorrect JSON formatting)
  • Print an error if you could not read the file.
  • Swapping the values contained in each line of the file with the corresponding JSON key-value pair for the SSG program variables.

When it came to tackling the work I did a git pull on Gustavo's repository to update my version of his repo. In order to implement this I used Yargs as this is what the original program was doing. I added an alias for "c" and "config" to allow for the user to enter a file. Using this, I stored it in argv.c and read it as a JSON file. I checked for errors including not being able to open it, or incorrect parsing:
alt text

Then, as mentioned, I stored the values in each of the Yargs CLI values.

alt text

Overall the code itself was not too crazy to implement. The next step was asking him to make a change, and I realized that when I first committed I didn't update the README to let the users know they can use a config file now. So he added my branch as a remote origin, and after I pushed my README changes Gustav did a "git fetch , git checkout main so that he would be in his production branch, then git merge to get my changes, and then git push to move them to his main branch.

I learned a lot in this lab about git remote and merging a branch that I didn't create. This will be useful knowledge when multiple people are working on my project. It allows me to add them as a remote origin and merge changes and close the pull request that way after pushing.

Discussion (0)