The git reset command can be used to undo the last comment in a git folder, and much more than just that. When called with no additional arguments it can be used as a way to unstage what has been staged for committing using the git add command. However with additional arguments it can be used as a way to make is called a soft reset, as well as also a hard reset. This is a command that I do find myself using now and then, so it is worth taking a moment to write a quick post on it.
The git reset command can be used as a kind of opposite of git add when staging files to be commited. However it can also be used as a way to reset the head of the got folder as well. When doing this there is what is called a soft reset as well as a hard reset.
So say you added some files to be committed, but then realize that you made a mistake, but did not commit yet. No problem just use the git reset command and give the path that you want to reset, or no path at all if you want to reset everything that was added and start over.
using the git reset method this way will not result in a loss of changes that where made, it just simply resets what has been added with the got add command. So it can be though of as an opposite of git add when staging files that have been changed.
If I want to undo the last commit, but keep the changes that have been made I can use the git reset command to do a soft reset like this.
So Basically this project just makes it so I can turn this:
Into just this.
There are many reasons why it makes sense to write my own commands. If I find myself doing the same thing over and over again that is a few steps chances are I should make it into a command.
I just need to add the following to the package.json file of the project to make it so I can install the project globally and then use it anywhere with the name that I set for it..
So here I have the indes.js file of this project. I am starting off the project with the shebang for nodejs as this will be a global script. In addition I am using the spawn method of the child_process module to launch the git command from within nodejs. The child process module is great as I can use it not just to run git commands, but anything that can be done in the command line of the operating system I am using.