How to integrate Git + Github + Google Drive?

2019-05-22 15:41发布

问题:

I am running Git on two computers, machine A (OS X) and machine B (Windows 10), while remote hosting on Github. My local working directories for both machine A and B are synced with Google Drive.

I noticed the other day that any time I make a commit on machine A (even when no changes occurred), machine B all of the sudden has modified files which need to be staged and committed.

$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   README.md
        modified:   helper_scripts/scriptA.py
        modified:   helper_scripts/scriptB.py
        modified:   helper_scripts/scriptC.py
        modified:   helper_scripts/scriptD.py

no changes added to commit (use "git add" and/or "git commit -a")

Once I run the following on machine B,

git add .
git commit -m 'some message'

I get the following message on machine B:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Then I check git status on machine A, and the whole process repeats again and again ... This appears to be unusual behavior because I am not making any changes to the files. I hypothesize that Google Drive syncing is causing the issue somehow.

How can I get Git, GitHub and Google Drive to play nice together so as to avoid this vicious cycle I seem to be caught in?

回答1:

Just don't.

It's only a matter of time before your git repo get corrupted and you will lose your work. Seriously, find a better way to backup your work.



回答2:

First double-check the nature of the diff reported in machine B (Windows)

Try again with a fresh synchronized repo, but this time done after having first typed (on Windows)

git config core.autocrlf false

That will prevent Git doing some automatic modification to files in order to change the eol style (LF vs. CFRL end of lines)