DEV Community

Discussion on: 3 ways to retain your dev flow between sessions 💪

Collapse
 
exadra37 profile image
Paulo Renato • Edited

Never leave code to be commit-ed in your machine... you may end up to learn it in the hard way, like when your disk breaks apart and you loose all your precious work.

I use ZSH shell that have pretty handy git alias:

╭─exadra37@thinkpap-l460 ~  
╰─➤  alias | grep gwip -  
gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"'
╭─exadra37@thinkpap-l460 ~  
╰─➤  alias | grep gunwip -
gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'

So my workflow is:

  • gwip to commit all dirty changes, including untracked files, therefore everything.
  • git push origin feature-wip to push my changes to a work in progress branch. This saves me in case my disk goes dead.

When I am back to the project:

  • gunwip to get back git to the same exact dirty stage it was before I applied gwip.

When I am ready to perform a clean commit:

  • git checkout feature to switch back to the branch from where I derivedfeature-wip.
  • git commit -sam 'my message' it may need git add . before if untracked files exist.
  • git push origin feature always play safe and push your most recent commits to upstream.

I hope that it helps someone :)

Collapse
 
mertsimsek profile image
Mert Simsek

wow that is wonderful!

Collapse
 
weirdmayo profile image
Daniel Mayovsky

Will this work on a bash shell alias?

Collapse
 
exadra37 profile image
Paulo Renato

yes it will, just add both alias to your ~/.bashrc or try Oh My ZSH and I bet with you that you will not come back to bash :)

I can live without Oh My ZSH, but life wouldn't be the same ;)

Collapse
 
sergsoares_15 profile image
Sergio Soares

This can be live change.

Thanks man

Collapse
 
exadra37 profile image
Paulo Renato

It was for me... Cannot live without Oh-My-ZSH ;)