3

I have a central Git repository hosted with GitLab, and my coding is done on either a laptop or desktop. Pulling the code to work on it on either machine and then committing and pushing when finished works fine, but I'd like to have a cleaner way to switch between laptop and desktop (sometimes I run out of time on the desktop and have to finish something on the laptop). Right now I'd have to commit and push from one machine, then pull from the other, but that's not ideal, since sometimes the switch has to happen when I'm in the middle of something and I'd rather not commit broken code.

Potential solution: Clone/pull from both machines into a synced Dropbox (or similar) directory, so that code is synchronized across machines automatically, then commit/push on my own terms (when the thing works, to keep my history cleaner and collaborators happy).

Is there any danger of corrupting the repo by checking it out in an automatically-synced Dropbox folder? Does the .git folder contain any environment-specific details or absolute file paths that might get conflicted in a cross-machine (and cross-OS, Windows-Ubuntu) sync?

Nick Faughey
  • 584
  • 1
  • 5
  • 10
  • I think this has been answered here - http://stackoverflow.com/questions/3973034/export-a-stash-to-another-computer. – amui Feb 04 '16 at 18:46

1 Answers1

1

Git repo in Dropbox works perfectly well, in fact many people do that for precisely this purpose. Shouldn't have any issue with cross-platform sync.

Though there's nothing wrong with committing broken code on a separate branch, where you can git reset --soft HEAD~ to remove the last commit but keep the changes in the working directory.

Alternatively just continue to push commits to that branch, then squash all into 1 commit when you are done with git rebase -i HEAD~<numOfCommits> then merge to master

Roy Wang
  • 11,112
  • 2
  • 21
  • 42