sevenseacat
sevenseacat

Reputation: 25039

Coming at git from a bzr/svn background

I've been using bzr for personal programming projects across my two computers for some time now, and syncing the repositories using Dropbox. So far I haven't had any problems with the following workflow:

(I know it more resembles a svn workflow, using the Dropbox as the central repository, but setting up svn server on both desktop and laptop to be able to use the synced Dropbox folder as the main repository did not appeal to me at all.)

And so on and so forth.

But now I'm learning Rails, and Rails is all about git. I've tried to use a similar workflow, and run into grief.

I've done some reading, and it appears clone was not the right command to use in the first place, and I should still be using push? 'git remote -v' is telling me:

origin  /home/karpie/Dropbox/Sites/Rails (fetch)
origin  /home/karpie/Dropbox/Sites/Rails (push)

But push still doesn't work...

Counting objects: 214, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (182/182), done.
Writing objects: 100% (192/192), 725.23 KiB, done.
Total 192 (delta 31), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/karpie/Dropbox/Sites/Rails
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/home/karpie/Dropbox/Sites/Rails'

I... don't really know what any of that means and it's quite intimidating.

So.... how can I grasp a proper workflow to use, if my way really isn't the 'git way', and how can I fix my current issue? I don't really mind nuking the repository that's currently in my Dropbox and on my laptop, as long as I don't lose what's on my desktop.

ps. And while I do have a github account, I'd rather not make my website development code public at this current time, so I'm attempting to use Dropbox instead.

cheers,

Karpie

edit: I'm thinking a GUI like Giggle might help me grasp this concept of 'branch for everything', unless anyone has any better ways of coming to grips with it,

Upvotes: 1

Views: 322

Answers (2)

Jakob Borg
Jakob Borg

Reputation: 24475

Background

Git has the concept of bare and non-bare repositories. The difference is that non-bare repositories contain a working space, i.e. your checked out files. This is the kind of repository you create and work in on your laptop and desktop machines. A bare repository doesn't contain any checked out files, and is what normally lives on server as a central repository. What git complains about in the error you get is that it doesn't like to push to a non-bare repository, since that would change things "under the feet" of whatever user might be using that repository.

Solution

  1. Create and use a repository on your laptop as you do now.
  2. Create a bare repository in Dropbox: mkdir Repo; cd Repo; git init --bare
  3. Push to the newly created bare repository.
  4. Everything else as usual. :)

Upvotes: 6

Alex Budovski
Alex Budovski

Reputation: 18456

When you create your dropbox repo, make it bare with git init --bare. Then you can push to it. The error explains why you don't want to push to a nonbare repo (i.e. one with a checked out copy)

Upvotes: 1

Related Questions