1

Apologies if this isn't an appropriate question for SO - if not please let me know and I'll delete/move it. I just haven't found any resources on this myself. Anything I google related to "multiple operating systems git" gives me pages for applications that work on multiple OS's like GitHub or Tower.

I currently work regularly between two operating systems - PC at the office, Mac at home. I've been managing this with with git by using my master branch for PC/Windows R code, while using a OSXversion branch for Mac R code. This is fine for whenever I'm updating Windows or Mac specific code on each branch (such as package installation instructions in the comments). Where this gets tricky is for general improvement in my code that applies to both Mac & PC. What I've been doing is manually copy-pasting any general improvements between my Mac/PC code or cherry picking my merges. Is there a better way to be doing this?

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69
spops
  • 572
  • 1
  • 7
  • 25
  • How does your question relate to R? It seems to be purely about git. – Roland Feb 14 '18 at 07:11
  • I was worried the question would be shut down for being "too broad" so I specified that I'm working in R, and perhaps there are R- or RStudio-based solutions. That being said I would welcome any more broadly git related answers that could be applied to any code, regardless of language! – spops Feb 19 '18 at 19:06
  • 1
    What are the major differences between the versions? For example, if you are setting paths for windows or Mac, there are ways to make your code detect which OS you are using and adjust accordingly. https://stackoverflow.com/questions/4463087/detecting-operating-system-in-r-e-g-for-adaptive-rprofile-files?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – alice m w May 16 '18 at 00:42
  • Major differences include file pathways, but also different packages to download and instructions on how to download for each OS. So, comments within the code – spops May 19 '18 at 21:05

1 Answers1

3

It's fine to store code that runs on different operating systems in a Git repository. Simply check out the repository on each of the operating systems you're going to be working on.

The only thing you need to watch for is the line endings, which. Unless you're dealing with files that specifically require native CRLF / LF end-of-line styles, you're best to turn the automatic conversion off.

This can be done with:

git config --global core.autocrlf false

Further notes on autocrlf can be found on the GitHub help page itself.

As for your actual committing, you'll want to be following Git Flow, and simply have a develop branch that bases off of master. From here, you'll want to create individual feature branches. These feature branches can be worked on whilst on either Windows or Mac. The package installation instructions should really go in your README.md file.

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
  • Thank you for the Git Flow link! So ideally what I should have been doing is making another, separate branch for "general improvement"? Eg., if I'm working on my Mac branch and decide something needs to be fixed for both Mac & Windows, make a 3rd branch that can be safely merged w both Mac & Windows without having to pick and choose which commits of the Mac branch I will want to merge with Windows later on? – spops Feb 19 '18 at 19:11