1

I am a newbie to Git and need to solve a simple task.
There is a cross-plarform open-source project in C++ on GitHub that I need to modify/patch. The development and debugging has to be performed on Windows (in Visual Studio), the production environment is on Ubuntu Linux. I am able to clone the sources from GitHub and compile them successfully on both platforms.

The goal is to track and propagate changes made on Windows and propagate them to Linux for production building. I've tried to simply copy the modified source directories from Windows to Linux, however there were issues with file permissions and line endings (CRLF vs LF) and the project failed to compile.

Could you please recommend me some kind of smart solution how to solve this, i.e. how to track source changes on Windows and commit them to Linux build machine? The GitHub project is work on progress and I have to apply updates as well (it should stay linked to GitHub).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
janrovner
  • 21
  • 2

2 Answers2

0

Use a .gitattributes directive in order to have your files eol converted to the OS native eol

# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text

(using core.eol is also possible)

See more in "GitHub: Setup / Dealing with line endings: Per-repository settings"

That will be more previse than core.autocrlf.
I recommend keeping that setting to false:

git config --global core.autocrlf false
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thank you very much for tips on CRLF. and what about transferring the code changes from Windows to Linux? Maybr I need to setup my own git server and push deltas to it from windows and pull from Linux or something like that... But I need to commit to another repository and then merge data from two repositories on Linux... But as I said - I am not familiar to Git (yet). – janrovner Apr 18 '18 at 05:16
  • @janrovner the goal of a .gitattributes directive is to handle the eol for you whenever you are doing a checkout of the repo (files are checked out with crlf on Windows, lf on Linux) – VonC Apr 18 '18 at 09:08
0

I solved the problem using Git as I created custom branch both on Windows and Linux and switched into it, i.e.

git checkout -b mybrach

then on the Windows side I produce patch files with

git format-patch .....

transfer them onto Linux machine and then apply patches there using command

git apply ...
janrovner
  • 21
  • 2
  • If the Windows machine can contact the Linux server somehow (shared mounted drive, SSH or https server), you could push directly from one repo to the other one (preferably a bare one) – VonC Apr 18 '18 at 11:27