Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git for file synchronization?

I have a need for distributed file synchronization. So first of all, any suggestions? My idea is git since speed is an issue.

My git knowledge is pretty rudimentary though so here's what I did.

I downloaded the portable git (I'm on PC so msysgit). I placed a copy into c:\root\git and a copy into c:\root\git c:\client\git\

I created a directory c:\temp\root\content and created some files in it

c:\root\content>..\git\bin\git.exe init
c:\root\content>..\git\bin\git.exe add *
c:\root\content>..\git\bin\git.exe commit -f
c:\client>..\git\bin\git.exe clone file:///c:\root\content

This creates a content directory but it is empty! The files committed to root are not there.

Also when I do a pull command I get

C:\temp\client\content\content>c:\temp\client\git\bin\git.exe pull
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Your configuration specifies to merge the ref 'master' from the remote, but no such ref was fetched

Clearly I'm missing a concept. What's going on?

like image 389
George Mauer Avatar asked Jan 23 '10 18:01

George Mauer


People also ask

What is synchronization in git?

git-sync is used for syncing a personal fork with the upstream repository the personal fork was created from. Syncing here means updating all the branches in the personal fork that are also present in the upstream repository.

Is there a git-sync command?

git-sync is a simple command that pulls a git repository into a local directory. It is a perfect "sidecar" container in Kubernetes - it can periodically pull files down from a repository so that an application can consume them. git-sync can pull one time, or on a regular interval.

How do I sync a file?

Step 1: Click Microsoft OneDrive in the taskbar. Click the Help & settings icon and then choose the Settings field. Step 2: Click the Account tab and then select the Choose folders button. Step 3: Click the files and folders you want synced to OneDrive.


3 Answers

Check into http://sparkleshare.org/

Sparkleshare gives you a user experience similar to Dropbox, except that it's underlying sync engine is git. It's not the most stable thing, but you can watch it's log output to see what git commands it's going to achieve seamless syncing. Once you learn those, you can simply make your own sync scripts that are stable. I think most of sparkleshare's problems are in the GUI.

like image 71
lee Avatar answered Sep 20 '22 16:09

lee


git-annex could be another tool to consider.

like image 28
gliptak Avatar answered Sep 18 '22 16:09

gliptak


Git can be a good tool for synchronizing source between development and production, for one reason: It makes it easy to "hot fix" in production and check the fix back into the tree. Of course you should always reproduce the bug in a development or test environment and fix it there, but sometimes you can't.

Instead of git add *, use git add .

Use git status before committing to make sure that the appropriate files are staged for commit.

like image 33
Wayne Conrad Avatar answered Sep 20 '22 16:09

Wayne Conrad