I do my work from three different workstations. I would like to be able to leave a workstation in the middle of a coding sessions and resume this work later on another workstation. Given that the code is shared via a remote git repo, I would like to use git to share this unfinished work.
In practical terms, unfinished work means
Most of the times these changes are temporary: not all the changes and most of the untracked files will finish in the final commit. An example of untracked file is a test file duplicated with 20 slightly different modifications for test purposes; I care about all these files only while I'm working on a certain problem and I do not want to lose time regenerating them when switching to another workstation.
I have seen other questions and solutions that use a branch to push these changes: while I am OK with this, there is the problem that these branches will be rewritten every time, requiring a git push --force
(I do not like --force
much) or allowing them to become very messy over the time.
What I would like to have is a simple command or git alias that allow me to store the current state of the work directory without "messing too much" with the git history. There must be a companion simple command or git alias that allow me to download these temporary changes from the other workstations.
Use git stash to save your changes to a file.
git stash
git stash show -p > myPatchFile
On the other computer apply them
git apply myPatchFile
You could use git add -A
to remove deleted and add new files. Then commit it into a branch named say my_current_work
. Exchange it via remote repo using --force
. You could share a new one remote which is only for you to make the main repo cleaner. Or if you have a network link between workstations you could push/pull changes directly between them.
Before merging your work into the master branch you do rebase -i
to clean up commit history.
As alternative to remote repo for exchanging you could send patches via e-mail (git-send-email
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With