1

I'm developing with my macbook during transport and with my pc at home. I have my project folder containing all php files and the .git folder. The problem is that I'm getting many conflicts when trying to sync the folders with rsync after I made changes on my macbook.

What is the best way to do that workflow? Only sync committed files, so there are no conflicts?

charihans
  • 85
  • 2
  • 10

3 Answers3

1

You should not try to rsync uncommitted files or files staged locally. Use git to stage these things. You can always commit them to a development branch and merge it back into mainline. Git already solves this problem.

Lucas Holt
  • 3,826
  • 1
  • 32
  • 41
  • Plus you can share commits criss-cross. That's the D in DVCS of git's description. Yes, you have to be careful with what you are doing. – vonbrand Mar 30 '13 at 18:57
  • Okay, so I only rsync after all files have been committed. What about the active branches? Has the active branch on my pc to be the same as on my mac before rsyncing? – charihans Mar 30 '13 at 19:01
  • 1
    Don't rsync at all, dude. Git syncs and merges across the network *already*. –  Mar 30 '13 at 19:42
1

You might get a lot of conflicts because your config core.autocrlf might be set to native, automatically converting end of lines to CR+LF (PC) or LF (Mac).

See for instance "How to repair CRLF in GIT repository to avoid merge conflicts".

I would recommend only using .gitattributes for managing eol style, as in "What's the best CRLF handling strategy with git?".

See more details on "How line ending conversions work with git core.autocrlf between different operating systems"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Forget rsync. Just commit changes to the local git repo, then git pull --rebase to suck in the changes on the other computer (after setting its remote to point to the first computer).

This does mean however that you have to connect your computers each time you sync up, which gets tedious. A less tedious way is to setup an intermediate git repo on a server you control somewhere, then from each computer sync to that networked server's git instance.

For example if you get a VPS hosting account with normal shell access, then after installing git on it, creating a networked repo is as simple as git init --bare. Then clone it from each of your machines and you're good to go, just push and pull to the intermediate repo to sync changes across machines.

Eg: if your VPS username is "myuserid" on a server running at IP 1.2.3.4, and you've created "mybarerepo" in your VPS home dir, then to clone it onto your local machine you type: git clone ssh://myuserid@1.2.3.4/~/mybarerepo

Magnus
  • 10,736
  • 5
  • 44
  • 57