Reputation: 11331
I have a work machine and a home machine, and on both is a clone of the same online repo. I make some changes that I do not have time to finish before I leave work, but I want to take them with me so I can work further at home.
I want to avoid:
Basically, is there a quick way to take my "work in progress" home with me, without making any pushes?
Upvotes: 2
Views: 164
Reputation: 129654
use
git bundle
It is designed for this purpose. It will store only what you tell it to.
Upvotes: 4
Reputation: 43842
This is a negative answer to save others the trouble: I thought that if your USB key is large enough to hold the repository, and you just don't want to wait for a copy each time, then git stash
combined with pushing to USB would be a suitable tool. However, it is not possible to simply push the stash state, since stash actually uses the reflog and not just the ref refs/stash
.
Upvotes: 0
Reputation: 1848
First, I should say that I also recommend Will Buck's WIP branch answer, since they are easy to create and destroy, and they are lightweight.
Anyways, what you are asking is possible.
You can create a set of patches from a set of commits, copy them to the USB and then apply them in your home.
All of these steps can be done with: git format-patch and git am.
git format-patch
will generate a list of patch files from the commits you specify.
git am
will apply specified patch files on top of your HEAD
.
The progit book has more information on how to work with these commands.
Upvotes: 0
Reputation: 1510
Creating a WIP branch really seems like the way to go here, it's really quite quick to do and easy to get rid of. That said, I would think if what you wanted to do truly was possible, the centrally-located 'diff' file would be in your .git folder. I don't really know about that though, even if it is possible, it seems dirtier and riskier than just creating the remote branch... :/
So, what I would do is
git branch WIP
git checkout WIP
push the branch to master
checkout the branch from home
git rebase -i once you're ready to commit (to squash the "unnecessary commits")
delete the remote branch
Once you get the rhythm of that, its really quite quick and painless, and the win of using a distributed VCS like git
Upvotes: 1
Reputation: 2828
I know you stated you did not want to branch or otherwise, however you could have your local branch and then push it to the git repository as a remote branch. You would then be able to go home and pull the remote branch down onto your machine at home and continue working on it. You can do this over and over, going home and going back to work how ever often you wish. Once finished you merge the remote branch into your (development or master branch) then delete it. The branch is like it never existed. In git you can also have private branches that will allow no one else to see the branch if your underlying git server supports that. The copying of the files or other ways you are trying to do it just take away from the usefulness of git since it is distributed and branching is cheap it is much easier to branch and then merge when needed. Having a lot of commits is not a bad thing.
Upvotes: 0