Skip to content
  • Home
  • Search
  • Tools
  • About
  • Terms of Service Agreement
  • Log In
  • Guest

GIT: I do love Git stash – Super hero when things go wrong

Posted on September 1, 2020January 21, 2021 By Andre Dias
versioning

Table of Contents

  • SCENARIO
  • HOW TO SAVE TIME WHEN THINGS GO WRONG?
    • RESTORING TO BEGIN AGAIN WHEN THIS APPROACH IS THE BEST CHOICE
    • WHAT ELSE GIT STASH DOES?

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! 🙂

  1. Create a tracking file.
    Take note in a .txt file, or whatever, of the main things done in the project.
    .
  2. 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!

 

 

Andre Dias
Andre Dias

Brazilian system analyst graduated by UNESA (University Estácio de Sá – Rio de Janeiro). Geek by heart.

Post navigation

❮ Previous Post: WEB: Site Performance – At Least a Quadruped Beast
Next Post: ANGULAR: Create an Angular 10 project using Bootstrap – INDEX ❯

Search

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
angular
bootstrap
browser
computer science
container
data persistence
database
devops
editors
hardware
health
hosting
info
internet
it
java
javascript
network
node.js
play
protocol
security
self-help
selfhelp
server
services
soft
software engeneering
sql
support
Systems
techs
Uncategorized
versioning
web
web design
windows
wordpress

Recent Posts

  • Angular From Scratch Tutorial – Step 9: Modal
  • Angular From Scratch Tutorial – Step 8: Miscellany
  • Angular From Scratch Tutorial – Index
  • angular: Reading JSON files
  • NODE.JS: SEQUELIZE: MVC Project – 4TH STEP

Categories

  • angular (19)
  • bootstrap (6)
  • browser (4)
  • computer science (4)
  • container (1)
  • data persistence (2)
  • database (11)
  • devops (1)
  • editors (1)
  • hardware (4)
  • health (2)
  • hosting (1)
  • info (1)
  • internet (2)
  • it (1)
  • java (13)
  • javascript (32)
  • network (6)
  • node.js (1)
  • play (1)
  • protocol (1)
  • security (4)
  • self-help (1)
  • selfhelp (1)
  • server (2)
  • services (1)
  • soft (1)
  • software engeneering (1)
  • sql (1)
  • support (2)
  • Systems (1)
  • techs (3)
  • Uncategorized (2)
  • versioning (6)
  • web (1)
  • web design (5)
  • windows (3)
  • wordpress (4)

Copyright © 2025 .

Theme: Oceanly by ScriptsTown

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT