How do I do an initial push to a remote repository with Git?

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:
    • mkdir project
    • git init
    • git add .
    • git commit #==> nothing to commit
  2. On client:
    • Create new project in RubyMine
    • Git init in top directory of project
    • Push changes to server #==> failed to push some refs to...

What steps am I missing?


Solution 1:

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.

Solution 2:

You can try this:

on Server:

adding new group to /etc/group like (example)

mygroup:1001:michael,nir

create new git repository:

mkdir /srv/git
cd /srv/git
mkdir project_dir
cd project_dir
git --bare init (initial git repository )
chgrp -R mygroup objects/ refs/ (change owner of directory )
chmod -R g+w objects/ refs/ (give permission write)

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

(Thanks Josh Lindsey for client side)

after Client, do on Server this commands:

cd /srv/git/project_dir
chmod -R g+w objects/ refs/

If got this error after git pull:

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details

git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream new origin/<branch>

try:

git push -u origin master

It will help.