Search code examples
gitbazaar

Is it possible to set up proper workflow between two repos in git?


I settled on using VCS for synchronization between my laptop and main computer. At that time, I liked bzr very much, so I used it. The workflow was simple - on main machine I had a script, which detected the appearance of laptop nearby and executed following steps:

  • bzr pull
  • bzr update
  • bzr push
  • ssh to laptop, update the repo there

Now, I slowly moving towards git - not the last reason for that is Github and git's superior speed. But I failed to set up the same workflow with git. First, it refused to push into checked-out repository - I solved that with receive.denyCurrentBranch = "warn", and doing git reset --hard. But this way, I lose any changes that I made on my laptop, if they were not commited. I tried using "git reset --merge", but (unlike bzr) it refused to merge some of the conflicting files.

Is there a way to solve these problems with git?


Solution

  • It's totally doable with git, but it seems to me like either you're not describing your environment completely (why push? where is the "origin"?), or you're confusing terms between bzr and git.

    On the "main computer" (it's a good idea that the main repo not be changed and be a "bare" repo, or have a third origin repo):

    git commit -am "Auto committing"

    no need for pushing here.

    then ssh to laptop:

    git pull <main_computer's remote> master

    This is provided you are both currently on the same branch, namely master, of course. There are more sophisticated ways to do it more safely, but for the simplest case of 2 machines and no third origin, this should do. Finally, you can set the merge strategy for collisions, see git help merge