-2

I have a Windows PC and a Ubuntu laptop that I use for development. One of my main issues is that I switch between them multiple times a day, but because they are different machines, I am unable to just pick up where I left off on another.

I've thought about several solutions but I am really unsure about which would be the best one.

  1. Github - I would have to commit everything, even unfinished or completely broken files which seems like it would be a mess and quickly pollute by repo with unnecessary commits.

  2. Remote Desktop/Teamviewer or VSCode Online - Seems like it would be laggy, and local hosting a web server would probably be a pain to configure

  3. VScode Liveshare - Looks promising, but latency might be an issue an again, I'm not sure how the terminal would work or how a local server would run

  4. Some sort of file sync - Haven't found one that is fast and that supports 2 way sync, but this one looks the most promising

9
  • 1
    What about a separate GitHub branch where you commit the files in whatever state they are? Commented Sep 21, 2019 at 22:14
  • Can't tell if your issue is that you have to recreate the session you left or that you keep forgetting to save your code before walking away. If you developed it all on a shared folder would it fix your problem? Commented Sep 21, 2019 at 22:26
  • 1
    Just curious: do you have equivalent development tools and environments on Windows and Linux, so you could simply check in the files to a git server (or GitHub) on one system, check them out on the other and continue your work immediately? Commented Sep 21, 2019 at 22:32
  • 1
    Why do you need to switch between multiple machines multiple times throughout the day? Can't you just set one machine as your development environment and the other setup only as a testing environment? Would using KVM switch so you can share one keyboard and mouse for two machines be suitable? Commented Sep 21, 2019 at 23:22
  • 1
    What build system do you use? How about a SMB share or NFS share? Also, what is the typical scale of code changes (e.g. couples of lines, or hundreds of lines) you make for each time you switch between the two OSes? Commented Sep 22, 2019 at 6:06

4 Answers 4

3

I've used 1,2 and 3 and 1 is by far the best.

  1. RDP is generally fine, but it relies on the other computer being a 'server' and turned on. If you develop on both machines you are going to get divirgence and complicate your life as you have both local and rdp sessions open on each.

  2. Is good for collaboration on a single file, but doesnt work well for multiple file projects and again has the 'which machine is the server?' problem

(new list)

  1. Just requires you to commit and push before changing machines. You should be commiting regularly anyway and a feature branch will mitigate the problems of commiting half finished work.
2
  • Some additional thoughts: 2 does not contribute to cross platform portability. For 1, couldn’t OP use a branch for isolating the daily work in progress in order to address the fear of polluting the repo ? Commented Sep 22, 2019 at 9:17
  • 3
    I would consider 'using branches to isolate WIP' as normal working practice. ie feature branches Commented Sep 22, 2019 at 9:49
1

If you are not willing or able to change your way of working so you could utilize a Git server or Github for syncing, I guess the most efficient way to accomplish what you want is to have your working files on a shared fileserver / NAS.

On the pro side, you won't have to sync anything. You can instantly stop working on machine A and immediately continue on machine B, and vice versa.

The downside is, you always need a high-speed durable network connection to the file server. If you cannot implement this, or don't want to invest into an NAS system, better go with option 1. Git provides you with lots of options to keep the "broken files" or "unfinished work" in unshared branches which do not get part of the main development line, and to clean up the history, if necessary.

1

Github - I would have to commit everything, even unfinished or completely broken files which seems like it would be a mess and quickly pollute by repo with unnecessary commits.

Git is basically designed to cope with development across multiple machines by multiple users. It offers a huge array of tools for dealing with this.

Feature branches

For each feature that you're working on, you can create a branch. Make changes to the branch and push them to github every time you need to switch machines. When you're finished and want to make a commit to the main branch ("master" or "develop"), you can first squash all the little messy changes into one clean change.

Alternatively, you can keep editing a single commit on the tip of the branch with "git commit --amend". I think this may require force-pushing though.

Patches

See https://stackoverflow.com/questions/4610744/can-i-get-a-patch-compatible-output-from-git-diff : you can create a patch file on machine A of your uncommitted changes, then apply it on machine B. However, going back again may be fiddly as you have to generate another patch, revert the local changes, apply the new patch ..

There's another workflow possible with "git format-patch" and "git am" (apply mail), which was intended for exchanging patches over email. Not too useful unless you're exchanging patches over email with yourself. And it requires you to commit.

Just share the files

If you commit to using only UNIX line endings, you can export the files from the Ubuntu machines as a SMB share and work directly on them with the Windows machines.

Or you could buy a NAS, like the popular Synology devices, and keep the files there.

Push between fileshares

The easiest way to do this is to have a shared directory between the two systems, but it can also be done if you can ssh into the Linux system from the Windows one.

$ git init localpush-A
$ git init localpush-B
$ cd localpush-A
$ git checkout -b devbranch
$ touch testfile
$ git add testfile
$ git commit -m "First commit"
[devbranch (root-commit) bfa4c99] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 testfile
$ git remote add other ../localpush-B
$ git push --set-upstream other devbranch
$ cd ../localpush-B
$ git branch -l -v
  devbranch bfa4c99 First commit
$ git checkout devbranch
Switched to branch 'devbranch'
$ git log
commit bfa4c99c27851d5596f125b613e10b990dcbc8f0 (HEAD -> devbranch)
Author: me
Date:   Mon Sep 23 10:59:44 2019 +0100

    First commit

$ touch differentfile
$ git add differentfile
$ git commit -m "Second commit"
[devbranch a294f9d] Second commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 differentfile
$ cd ../localpush-A
$ git pull other devbranch
From ../localpush-B
 * branch            devbranch  -> FETCH_HEAD
   bfa4c99..a294f9d  devbranch  -> other/devbranch
Updating bfa4c99..a294f9d
Fast-forward
 differentfile | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 differentfile

(Full explanation available on request, this answer is already getting long)

0

From your description, it is not really clear if you really need two physically separated machines, or just a Windows and a Linux environment. If it is the latter, you could consolidate your Windows and Linux environments on one machine (with a shared file system).

Virtualization is the usual approach for this, where one OS is the host, and the other one the guest system. There are several option for this available, like VM Ware, or Virtual Box, all of them support shared file systems. IMHO the easiest choice might be the Windows Subsystem for Linux, which will happily run Ubuntu on your Windows PC.

5
  • 1
    WTF?! 5 downvotes and 2 delete votes for something I've personally been doing without problems since pretty much the first WSL build. WSL took away the need to switch between a Windows and an Ubuntu PC. I have seen some outright stupid voting on SE sites but this one tops all of them. Commented Sep 23, 2019 at 7:01
  • @DocBrown: That just confirms my point. I had the same problem as that in the question (needed two machines), installed WSL, and then I needed only once machine. And importantly, that gave me a single file system. WSL solved for me this exact problem. Commented Sep 23, 2019 at 7:27
  • I now see what you mean. But from what you wrote in the answer, it is pretty unobvious that this might be a solution for the OPs problem (which I still wonder). Write a better answer, get better responses. Or wait a moment, let me edit your answer in shape based on your comment. Commented Sep 23, 2019 at 7:32
  • I am done here. Please double check if I got your intentions right. Commented Sep 23, 2019 at 7:47
  • Virtualization is indeed another reasonable approach. Commented Sep 23, 2019 at 8:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.