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 content originally appeared on DEV Community and was authored by dbelokon

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. 🦾


This content originally appeared on DEV Community and was authored by dbelokon


Print Share Comment Cite Upload Translate Updates
APA

dbelokon | Sciencx (2021-10-09T05:10:44+00:00) Experience Working with Remote Repos. Retrieved from https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/

MLA
" » Experience Working with Remote Repos." dbelokon | Sciencx - Saturday October 9, 2021, https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/
HARVARD
dbelokon | Sciencx Saturday October 9, 2021 » Experience Working with Remote Repos., viewed ,<https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/>
VANCOUVER
dbelokon | Sciencx - » Experience Working with Remote Repos. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/
CHICAGO
" » Experience Working with Remote Repos." dbelokon | Sciencx - Accessed . https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/
IEEE
" » Experience Working with Remote Repos." dbelokon | Sciencx [Online]. Available: https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/. [Accessed: ]
rf:citation
» Experience Working with Remote Repos | dbelokon | Sciencx | https://www.scien.cx/2021/10/09/experience-working-with-remote-repos/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.