charihans
charihans

Reputation: 95

Git workflow with 2 pcs/macs

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?

Upvotes: 1

Views: 108

Answers (3)

Magnus
Magnus

Reputation: 11396

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://[email protected]/~/mybarerepo

Upvotes: 0

VonC
VonC

Reputation: 1323045

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"

Upvotes: 1

Lucas Holt
Lucas Holt

Reputation: 3826

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.

Upvotes: 1

Related Questions