DEV Community

Alex Romanova
Alex Romanova

Posted on

Git rebase, amend and refactoring

The time has come! It is now an actual task to improve on our written code. Problem is... I have been doing that as I kept working on my program. Every other improvement I had in mind is already a documented issue and, frankly, not an easy one, since I tried implementing them before. Ah, yes, the old roadblocks I couldn't climb before standing here again.

Attempt at an issue

So far I have 3 "leftovers" in my issues. Sync/async, default paths (actually means I want to have the user input some options, or choose some things in the console. And for completing this issue I need to first complete the async one.) and yargs. Yargs is a more recent one, while also being an unattempted one so far. Looked doable. Note past tense in looked. It all went fine at first, I had examples to look at, I knew the steps to change my code. As it usually goes in programming fairy tales, everything was perfect until you had to run the code. I have managed to fix some things, but others I couldn't. What I noticed is the simplicity and stupidity of my mistakes, such as having a different variable name, or not including a file. Sure, some actually taught me things, such as using module.exports. The fact, however is - shit doesn't work.

Another way

Since I was already behind in the project, I decided to find something else to fix. After all, I know my code has many bad parts. It wasn't difficult to find nitpicks such as..

Yea, you know the ones. I squashed my changes, which wasn't fun at first, since I had to deal with VIM again and remember my first semester. :wq and i - literally all I had to know for this (ignoring all the other commands we learned like: replace one character, edit one word, find a specific thing, move with hjkl instead of arrows......... yeeeeeeeeeaaaa I used to know this. Long time ago. In my past life. No more!).

Rebasing was something I didn't fully understand. Specifically the part on.... why? Amend was understandable, I actually liked that one.
Here are messages that I changed with amend:

Just some clarifications on what I actually did. Yea, I'm not Einstein, I know. This was really mostly to practice git commands, rather than doing actually useful refactoring. My actual refactoring doesn't work. Look at it! Now it's not even up to date with my smol refactoring. There's honestly nothing interesting to look at in the second one.

Top comments (0)