Table of Contents
SCENARIO
Node.js project using Angular, etc.
Usually, manually copying a project like an example above may take a very long time.
Making synced snapshots using a sync tool is a better approach.
A much better alternative is considering using a versioning tool.
I chose Git.
Probably, you may apply the concepts suggested here using another versioning tool that provides similar features as that Git provides.
HOW TO SAVE TIME WHEN THINGS GO WRONG?
Just using Git without a strategy is not enough.
For simple things, it may suffice. Unfortunately, most of the time, simple things don’t require versioning control.
Here you get my recipe! 🙂
- Create a tracking file.
Take note in a .txt file, or whatever, of the main things done in the project.
. - Before an important operation, always commit your project.
After the commit, take note of the commit revision number in your tracking file.
This procedure will help to remember what each commit has in details, what you’ve done, what you get if you checkout to that revision number.
Important operations are those that may screw your application.
Examples:
– installing a new package or library.
– performing a long configuration including many steps.
– creating a new module that it is shared with others.
– and all those procedures involving many files, classes and configuration files.
.
RESTORING TO BEGIN AGAIN WHEN THIS APPROACH IS THE BEST CHOICE
For example, you are supposed to create a new component.
First, make sure that your application is running stable.
Commit it and take note.
Example using an Angular project:
Using the example above, suppose that something went wrong during the task.
You try to fix thinking that it is something fast to fix but the clock is ticking and your site still fails to work as it should.
It comes two possibilities.
One is to use your notes to recheck what you’ve done.
Another, and most usual, is that you didn’t take note of detailed information, so the notes are not enough to lead you to a fast solution.
Much better is beginning again from the previous state without loosing your current code or detaching the branch (when you commit the current state and checkout to the previous commit number).
In this case, git stash is perfect!
You do:
git stash
And everything comes to what it was before starting to work in your new task.
After git stash, you may restart coding from the beginning saving too much time trying to find out what has gone wrong.
WHAT ELSE GIT STASH DOES?
The previous code is preserved in a temporary copy working copy that you may re-apply later or not.
In the example above, we usually do not re-apply, but in other cases this command is very useful when you desire to pull information as if you hadn’t started coding.
To do this, you stash, then you pull, and to re-apply your code you do “git stash pop”.
Get more detailed information at:
bitbucket
git doc
Enjoy an easier life!
Brazilian system analyst graduated by UNESA (University Estácio de Sá – Rio de Janeiro). Geek by heart.