DEV Community

cychu42
cychu42

Posted on

Working With Remote Repo

What is it?

This week, I try to work with remote repository through use of git. Yes, just typing command in my command line and not click buttons on GitHub like my old lazy self.

What was I working on?

I was adding a configuration option via -c or –config option, where it will accept a JSON file as config file to use the values inside instead of other options.
It waseasy to plan for what and how I want to do, since it’s just about reading a file and using the variables.
The hard part was figuring out how my code would be compatible with the repo I tried to add it to.
I was working on this repo, and I opened an issue and filed a pull request.
This static site generator tool doesn’t use any options but accept arguments directly, so I had to use minimist package to parse options. There are a few variables that aren’t listed in the config module, such as stylesheet url, so I added them and use the variables from the config module instead. I also ended up slightly rewriting the language option code so the program would actually use the code from the author. Overall, there where bits and pieces of code for other options that aren’t entirely functional as options, so I ended up rewriting them a bit for the configuration option to work.

Changes

  • Language uses the config module value
  • Stylesheet uses the config module value
  • Language, stylesheet, input path, post folder path, output path can be set by JSON config file
  • Installed minimist module to support use of option flags for this feature
  • Allows language option code be used as a function in post creation functions: createPost(), createPosts(), createSingle() -This utilizes config module value
  • Allow default stylesheet to be changed, as a function in post creation functions: createPost(), createPosts(), createSingle()
    • This utilizes config module value
  • If any option is missing or purely whitespace, the default config module value will be used
  • Updated README.md to include this support at the bottom of the document.

I was also accepting a pull request from someone to do the same for my own static site generator.

Using Git

Once I’m familiar with the commands, most of the work was conceptualizing what’s happening. I had to remember what version of code sits at which repo and branch. I had to remember which remote repo has my original work, which one has the pull request from another programmer, where I’m pulling the code from, and which branch the new code should go to.

Other than raw brain power, I suppose it helps to have good naming convention to keep track of where you put things, like the names you give to each remote repo you link to and each branch you have.
Alternatively, take notes on a piece of paper or TXT file.

Next Time

I learned a lot about working with multiple remote repositories and keeping track of multiple branches.
I also learn a lot of commands to fetch and pull code and make tracking branches. Next time, I’ll probably try to come up with better names for remote repo and branches I added to track them better from the start.

Top comments (0)