tags:

views:

42

answers:

2

My workflow is basically:

  • Create a repo on my desktop PC
  • Do some work on it and commit changes
  • Clone onto my laptop
  • Work on that, commit changes

Now I want to synchronise the changes with my desktop. Trying git push desktop.local:~/my-repo will fail, because the master branch is already checked out. I know of two solutions to this:

  1. Create a third, bare repository in another directory on my PC and update both working copies from there. But a single central repository with two working copies checked out sounds like... SVN! Except clumsier, because I can't just use svn update and svn commit to synchronise with this central repository — extra steps are required to actually update the central repo from changes committed to a working copy in Git.

  2. Push to a separate branch and merge that branch in on my desktop working copy. This isn't too bad, but...

...what I don't understand is this: if I just SSH to the desktop PC and issue git pull laptop.local:~/my-repo, it works! It pulls the committed changes in and updates the checked out master branch, no questions asked. Why can't git push do this itself?

So here's my question: is there a command that works the same as ssh-ing in to my desktop PC and issuing a pull?

A: 

You could use ssh-fs to mount your desktop, add a remote on your laptop to that repo, then pull from that remote.

Adam Vandenberg
A: 

You can set receive.denyCurrentBranch to warn to allow pushing to your desktop PC. However, this is dangerous. If there are some commits in your desktop PC, this push will cause confuse.

The following is manual of receive.denyCurrentBranch for your reference.

  receive.denyCurrentBranch
      If set to true or "refuse", receive-pack will deny a ref update to
      the currently checked out branch of a non-bare repository. Such a
      push is potentially dangerous because it brings the HEAD out of
      sync with the index and working tree. If set to "warn", print a
      warning of such a push to stderr, but allow the push to proceed. If
      set to false or "ignore", allow such pushes with no message.
      Defaults to "refuse".
czchen
Would it have the same problems with `git pull` from the desktop, though (I haven't tried `pull`-ing with extra commits on the desktop)? I don't understand why it's seamless when I `pull`, but not when I `push`.
detly