6

I have a personal project using git that I often hack on across multiple computers, hosted on Github. Since I work on this at home I tend to get interrupted fairly often. I'll be in the middle of a statement, and dinner will be ready or I need to change a diaper. And when I get back to coding I may be on a different computer. What's the best way to get the most up-to-date version?

I think the most orthodox answer would be to commit and push. I commit fairly often but committing here seems messy to me. The code may be in a completely broken state where I was in the middle of a thought. To commit and publish it, even on a topic branch, doesn't seem right to me. It's also more steps than I would prefer.

Until now I've been using DropBox. But this appears to have lead me to a corrupt index. It's not hard to imagine because those syncs can be across different versions of git and different operating systems. So I'm afraid this it out.

Does anyone have a better alternative?

mmalone
  • 1,122
  • 9
  • 10
  • Maybe setting up gitolite at home, as a complement to github? – fge Dec 25 '11 at 23:17
  • 1
    I'd just shove it on that temporary branch -- you can always delete the branch from GitHub again later once you've tidied things up. No point in overcomplicating things :) – Stuart Golodetz Dec 25 '11 at 23:21
  • If you did @StuartGolodetz's suggestion, I'd suggest naming your branches something like don't_clone_temp_feature_name, just to minimize the possibility that someone grabs your temporary branch. – wadesworld Dec 25 '11 at 23:24
  • 1
    @StuartGolodetz I was thinking of some kind of a git alias or plugin. Call it something like "spush": stash and push. Then if you run "spull" it would fetch and merge in that most recent spush. Something where I don't need to be bothered with coming up with a branch name, recalling that branch name later, running the multiple commands, etc. – mmalone Dec 26 '11 at 00:55
  • @mmalone: Not sure if there's an 'easy' way to do that, but you could probably write a couple of batch files to do it. – Stuart Golodetz Dec 26 '11 at 13:57
  • This question might be relevant: http://stackoverflow.com/questions/1550378/is-it-possible-to-push-a-git-stash-to-a-remote-repository – Stuart Golodetz Dec 26 '11 at 14:03

3 Answers3

2

An alternative to using Git to keep a codebase in sync across computers is to keep the actual codebase on your dropbox. Essentially, it just a local folder that's synchronised, so that whatever computer you're on (as long as you have saved your current work) it will be synced for you. It saves the step of pushing and pulling to a git repo on dropbox.

Abizern
  • 146,289
  • 39
  • 203
  • 257
  • Yeah this is what I've been doing, but recently ended up with a corrupt index. Not sure how it happened. – mmalone Dec 26 '11 at 00:57
  • @mmalone No, I don't mean keep a Git repository on Dropbox, but your actual project files. – Abizern Dec 26 '11 at 01:32
  • 1
    @abizem Sorry, maybe I'm missing your distinction. I'm talking about the directory with my working directory with code, which would also include the '.git' directory and the index inside of that. Are you thinking of something different? – mmalone Dec 30 '11 at 23:33
  • Yes, ignore the ".git" folder, then it syncs just the worktree – xenithorb Jun 10 '16 at 19:54
1

I'd suggest writing a small script to rsync the required directories to all of the specified machines. Should be very simple and can be aliased so it's just a one liner from the terminal.

Where I work I do this often, dev on local machine using vhost to test but when I need to test on a mobile device, I can rsync everything to the public dev server and use the vhost there from the mobile device.

sciritai
  • 3,688
  • 1
  • 17
  • 22
0

One solution would be to use a private server. Either pay for a GitHub micro account, or just use some server to which you already have access. Then you'd commit, and push to the private server. When the code is ready you'd push to the public server after squashing / cleaning up commits, etc.

wadesworld
  • 13,535
  • 14
  • 60
  • 93