4

I have a git repository on a Dropbox folder, shared between a Linux machine and a Windows machine. I try to sync only on the Windows machine, because I am aware of "issues" that may arise. Occasionally I do a small commit on the Linux box, though, to track my changes,

But now I am really curious, what git is doing: Id did not touch the file fonttest.tex, but git reports me it has been modified:

towi@havaloc:~/Dropbox/latex$ git status fonttest.tex
# On branch master
...
#   modified:   fonttest.tex

And the diff lists the whole file: All lines deleted, and inserted again. Ok, probably an CRLF-issue. So I ask todos and fromdos to convert back-and-forth with and without CR and CRLF. But -- you guess already -- no change for git: All lines changed.

Hmm, I thought, Since I know nothing has changed, I get a clean copy:

mv fonttest.tex fonttest.tex1
git checkout fonttest.tex

And because I am a curious person, want to see the difference:

diff fonttest.tex fonttest.tex1

nothing. Really?

towi@havaloc:~/Dropbox/latex$ md5sum fonttest.tex*
d3544bd060504ebb682b2e446375b3b3  fonttest.tex
d3544bd060504ebb682b2e446375b3b3  fonttest.tex1

Really. And what is git thinking about it?

towi@havaloc:~/Dropbox/latex$ git status fonttest.tex
# On branch master
...
#   modified:   fonttest.tex

Man, you just checked it out for me! What's the matter here? Why is git thinking the file has changed?

Here is an excerpt of my config. I did make some adjustements concerning CRLF, by following someones tip for Dropbox sharing. But... I just cant follow git here.

towi@havaloc:~/Dropbox/latex$ git config -l       
diff.renames=copies
apply.ignorewhitespace=change
apply.whitespace=nowarn
core.whitespace=cr-at-eol
core.repositoryformatversion=0
core.filemode=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.eol=lf
core.autocrlf=input

2 Answers 2

1

While it's probably okay to keep a Git repository inside a Dropbox folder, the problem is that multiple systems will be sharing a working directory and an index if you keep them there. Git wasn't really designed for this sort of usage.

My guess is that the problem you're running into has something to do with this. Perhaps it's a line-ending issue, since your Windows machine will use \r\n but your Linux machine will use \n.

If you want to use Dropbox to keep Git repositories in sync, I would recommend keeping a bare repository in Dropbox, then pull from and push to it from separate repositories. This way, the bare repository will be synchronized via Dropbox, but each operating system will keep its own working directories and indexes separate.

You would do this on your Linux machine:

mv ~/Dropbox/latex ~/
cd ~/latex
git init --bare ~/Dropbox/latex.git
git remote add dropbox ~/Dropbox/latex.git
git push dropbox master

Then, on your Windows machine do this:

cd %USERPROFILE%
git clone Dropbox\latex.git
cd latex
git remote rename origin dropbox

From this point forward, you would do all your work inside ~/latex (Linux) and %USERPROFILE%\latex (Windows). When you make commits you want to share, you would use git push dropbox master in one repo and git pull dropbox master in the other.

1
  • Good idea. I didn't think of that. This way I could also handle the required different paths in both OS'es.
    – towi
    Commented Jan 17, 2013 at 9:48
0

You're snipping some potentially important information from the git status output. Does git status say "Changes not staged for commit" or "Changes to be commited". If it says the latter, the reason the file is always showing as modified is because you have uncomitted changes in the index.

1
  • not staged. I can the git add the file and it appears as staged for commit
    – towi
    Commented Sep 2, 2011 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .