如何集成 Git + Github + Google Drive



我在两台计算机上运行Git,机器A(OS X(和机器B(Windows 10(,同时在Github上远程托管。我的机器 A 和 B 的本地工作目录都与 Google 云端硬盘同步。

前几天我注意到,每当我在机器 A 上进行提交时(即使没有发生任何更改(,机器 B 都会突然修改需要暂存和提交的文件。

$ 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")

一旦我在机器 B 上运行以下命令,

git add .
git commit -m 'some message'

我在机器 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

然后我在机器A上检查git status,整个过程一遍又一遍地重复......这似乎是不寻常的行为,因为我没有对文件进行任何更改。我假设谷歌云端硬盘同步以某种方式导致了这个问题。

我怎样才能让 Git、GitHub 和 Google Drive 一起玩得好,以避免我似乎陷入的恶性循环?

只是不要。

您的 git 存储库损坏只是时间问题,您将丢失您的工作。说真的,找到一种更好的方法来备份您的工作。

首先仔细检查机器 B (Windows( 中报告的差异的性质

使用新的同步存储库重试,但这次是在首次键入(在 Windows 上(完成的

git config core.autocrlf false

这将阻止 Git 对文件进行一些自动修改以更改 eol 样式(LF 与 CFRL 行尾(

最新更新