DEV Community

dbelokon
dbelokon

Posted on

Experience Working with Remote Repos

This week I was contributing to the dodo-ssg's remote repo. My intention was to add a feature so that when someone types in "--config" or "-c" followed by a path to a JSON file, the program will read its contents and execute the commands inside of it. This is a useful feature when you don't want to see a super long line in the command line interface filled with a bunch of commands. Here is my PR.

Implementation

The way I decided to implement this feature was that I checked whether the user passed the config flag and if they did, I would try to open and parse the JSON configuration file. After this, I extracted the accepted properties from the JSON, overwriting any arguments that the user might have passed before.

Some Torturings

When I first started working on the dodo-ssg, I felt like my brain was melting. I think that it had to do with the fact that in the last couple of months, I have been mostly working with C#, Python, and a bit of Java, which have a completely different feel compared to JavaScript. It took me a while until everything clicked in ๐Ÿ’ก.

When I was looking at a variable named "fs" and it took me a while to unfreeze and figure out that that was to store a file system๐Ÿ˜ณ

Moreover, I remembered that when checking if a variable is of type string, we have to also check whether is it is an instance of a String object, because JavaScript is weird๐Ÿ™ˆ.

Git It

This time, I got to learn some more commands to work with Git.
Here is what I am adding to my collection this time๐Ÿ˜‹:

Track a remote repo:
git remote add remote-repo-name remote-repo-url

Get commits and branches from the remote repo:
git fetch remote-repo-name

Switch to a branch from the remote repo:
git checkout remote-repo-name/branch-name

Merge a branch from a remote repo:

git checkout local-branch # switch to local branch
git merge remote-repo-name/branch-name

What to do when you committed to the wrong branch? ๐Ÿ’ก

While working on the project, I had a little "committing to the wrong branch" situation. I couldn't figure out how to "uncommit" from the wrong branch and then commit to the proper branch. If you ever find yourself being tortured with this like I did, here are some tips:

  1. Move the main branch to its previous commit (before your wrong commit):
    git reset HEAD^

  2. Create a branch that you want to commit to
    git branch issue-15

  3. Move the branches location to the commit that dealt with fix
    git reset ac8bdfb

Basically, here, we are just replacing the "wrong" branch with the "correct" branch so our commit appears in the branch we intended it to be.

Mindset and Motivation

This time it took me a while to actually sit down and start working on this contribution(๐ŸŒ!!) because I didn't know what solution to come up with. I learned that it is better to start working on the problem as soon as possible even if it just means setting everything up for the project or coding the first step of a solution. Because the more you think, the more fears come into your mind and it just becomes harder and harder to get started. In reality, most of the time it is easier than you think๐Ÿ˜….

Next time, I will start working on a problem as soon as I can, even if I am scared because I can't think of any solution. ๐Ÿฆพ

Discussion (0)