views:

425

answers:

3

I've read through countless tutorials and I keep coming up short. Here's what I've got:

-- I'm running RubyMine on my Windows desktop
-- I've installed Git on my WebFaction hosting account per their instructions
-- Git appears to be working fine on both machines

Here's what I'm doing:
1. On server:
         a. mkdir project
         b. git init
         c. git add .
         d. git commit <--- "nothing to commit"
2. On client:
         a. Create new project in RubyMine.
         b. "git init" in top directory of project
         c. "Push changes" to server <---- "failed to push some refs to...".

What steps am I missing?

+1  A: 

You have to add at least one file to the repository before committing, e.g. .gitignore.

piquadrat
I guess the way I'm trying to use it is to add the files initially from my client, since that's where I write the code. Is that conceptually out of place in git? Do I need to commit on the client first and then push to the server?
Donald Hughes
A: 

You need to set up the remote repository on your client:

git remote add origin ssh://myserver.com/path/to/project
Dave Bacher
I ran that command, but a "git push origin master" still results in a "failed to push some refs".I tried doing a "git pull origin master" and received a "couldn't find remote ref master".
Donald Hughes
I'm not sure whether it makes a difference, but my remote repositories are created with `git --bare init` as @Josh Lindsey recommends.
Dave Bacher
+7  A: 

On server:

mkdir my_project.git
cd my_project.git
git --bare init

On client:

mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin [email protected]:/path/to/my_project.git
git push origin master

Note that when you add the origin, there are several formats and schemas you could use. I recommend you see what your hosting service provides.

Josh Lindsey
Worked perfectly!
Donald Hughes
The only thing I changed, since I'm working out of RubyMine, is that I replaced the touch .gitignore with creating a rails project with its 66 default files. Thank you very much!
Donald Hughes
Kudos for listing the commands. This is how I've set up remote repositories too.
Dave Bacher
I should add that if you want other people to collaborate with you on this repo, you should add `--shared` to the end of the `git --bare init` command. This will setup the necessary permissions.
Josh Lindsey