views:

136

answers:

1

I have an server (available via ssh) on the internet that my friend and I use for working on projects together. We have started using git for source control. Our setup currently is as follows:

  • Friend created repository on server with git --bare init named project.friend.git
  • I cloned project.friend.git on server to project.jesse.git
  • I then cloned project.jesse.git on server to my local machine using git clone jesse@server:/git_repos/project.jesse.git
  • I work on my local machine and commit to the local machine. When I want to push my changes to the project.jesse.git on server I use git push origin master. My friend is working on project.friend.git. When I want to get his changes I do pull jesse@server:/git_repos/project.friend.git.

Everything seems to be working fine, however, I am now getting the following error when I do git push origin master:

localpc:project.jesse jesse$ git push origin master
Counting objects: 100, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (76/76), 15.98 KiB, done.
Total 76 (delta 50), reused 0 (delta 0)
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning: 
warning: To squelch this message, you can set it to 'warn'.
warning: 
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To jesse@server:/git_repos/project.jesse.git
   c455cb7..e9ec677  master -> master

Is this warning anything I need to be worried about? Like I said, everything seems to be working. My friend is able to pull my changes in from my branch. I have the clone on the server so he can access it since he does not have access to my local machine. Is there something that could be done better?

Thanks!

+4  A: 

You should set up a bare repository on the server. A bare repository contains only the version history information that is usually in the .git directory in your repository root. You can clone from it or push to it like with any other repository.

Bare repositories are created with

 git init --bare

If you already have some version history make a bare clone

git clone --bare git://some/where

As for your warning see this question.

honk
My bad...I had used git init --bare when I had created the first repository. +1 for the link.
Jesse
What I had been missing was the --bare when I cloned the repository. Thanks!
Jesse