threads / discuss / 22033

Newbie to git

Subject: Newbie to git

## tl;dr

12 messages between Dec 27, 2009 and Dec 29, 2009.

replies: 11people: 6as markdown or json

Jorge Bastos· Dec 27, 2009, 16:12 UTC · lore
Howdy people,

I'm a using of git for several time, but now I have the need to a git server. My question, where can get a howto for reallyyyy newbies on git server?

I have part of it setup but still not working.

Thanks in advanced, Jorge,

mysql.jorge@decimal.pt· Dec 27, 2009, 17:45 UTC · re: Jorge Bastos · lore

Re: Newbie to git

> I'm a using of git for several time, but now I have the need to a git
> server.
> My question, where can get a howto for reallyyyy newbies on git server?
One question:
I've created a project on the server with:

mkdir project.git cd project.git git init

-and now locally, created a directory, and cloned this, it said that i was cloning an empty repo, fine about that. -now i added something locally, i get: (locally this is on a windows machine with tortoiso git)

-- git.exe push --tags "origin" master:git://192.168.1.206/projects.git

error: src refspec master:git does not match any. error: failed to push some refs to 'git://192.168.1.206/projects.git' --

I've read somewhere that i have to init both repos, remote and local to the same branch, is it correct?

My idea is:
- clone remote repo
- add projects locally and commit them to remote
how can this be done easylly?
Howard Miller· Dec 27, 2009, 20:12 UTC · re: mysql.jorge@decimal.pt · lore

Re: Newbie to git

2009/12/27  <mysql.jorge@decimal.pt>:
Show 22 quoted lines
>> I'm a using of git for several time, but now I have the need to a git
>> server.
>> My question, where can get a howto for reallyyyy newbies on git server?
>
> One question:
>
> I've created a project on the server with:
>
> mkdir project.git
> cd project.git
> git init
>
> -and now locally, created a directory, and cloned this, it said that i was
> cloning an empty repo, fine about that.
> -now i added something locally, i get: (locally this is on a windows
> machine with tortoiso git)
>
> --
> git.exe push  --tags  "origin" master:git://192.168.1.206/projects.git
>
> error: src refspec master:git does not match any.
> error: failed to push some refs to 'git://192.168.1.206/projects.git'

Firstly, I would have a serious look at 'gitosis' for the server end (there are other similar projects I believe).

Secondly, the push command is wrong. You don't need to supply the remote URL again... that's what 'origin' is telling the push command, which remote to use. This would have been established by the original clone.

Also, again, be careful with 'empty' repositories. (again AFAIK) an empty repository is just that, it doesn't even have a master branch so you really need to check out a branch and commit something before pushing makes much sense. I'm sure this is not 100% correct but you'll be safe that way!

Howard
mysql.jorge@decimal.pt· Dec 27, 2009, 21:55 UTC · re: Howard Miller · lore

Re: Newbie to git

Hi Howard,
Show 13 quoted lines
> Firstly, I would have a serious look at 'gitosis' for the server end
> (there are other similar projects I believe).
> 
> Secondly, the push command is wrong. You don't need to supply the
> remote URL again... that's what 'origin' is telling the push command,
> which remote to use. This would have been established by the original
> clone.
> 
> Also, again, be careful with 'empty' repositories. (again AFAIK) an
> empty repository is just that, it doesn't even have a master branch so
> you really need to check out a branch and commit something before
> pushing makes much sense. I'm sure this is not 100% correct but you'll
> be safe that way!
Well, gitosis even made me more confused :P

Let me reask: I'm running git deamon under supervisor with:

/usr/lib/git-core/git-daemon --syslog --export-all --enable=receive-pack --verbose --base-path=/home/apache/gitprojects

then i went to /home/apache/gitprojects and runned:

git init git add .

but for example, CGIT web interface says:

-- Not a git repository: '/home/apache/gitprojects' generated by cgit at 2009-12-27 21:54:47 (GMT) --

what could i be missing here? I've been reading howto's i find on the web, but all lead me to the same point, what i did and non work.. (with me).

Jorge,
Andreas Schwab· Dec 27, 2009, 22:34 UTC · re: mysql.jorge@decimal.pt · lore

Re: Newbie to git

<mysql.jorge@decimal.pt> writes:
> then i went to /home/apache/gitprojects and runned:
>
> git init
You probably want to create a bare repository in this directory:
$ git init --bare foo.git
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
mysql.jorge@decimal.pt· Dec 27, 2009, 23:00 UTC · re: Andreas Schwab · lore

Re: Newbie to git

Hi Andreas,
> You probably want to create a bare repository in this directory:
> 
> $ git init --bare foo.git
> 

Ok one more point, seams to be that! Forgive my really newbie question:

not i have: /home/apache/gitprojects/mydir.git

created with: git init --base mydir.git
Now, inside here, what should i do to create my projects:

mkdir myproject1 cd myproject1 git init touch a.txt git add . git commit -m "1st commit"

am i correct or not really?
Junio C Hamano· Dec 28, 2009, 02:18 UTC · re: mysql.jorge@decimal.pt · lore

Re: Newbie to git

<mysql.jorge@decimal.pt> writes:
> Hi Andreas,
If you are addressing Andreas, why does your mail have:
    To: <git@vger.kernel.org>
    Cc: <git@vger.kernel.org>
and no other addressee???
Show 15 quoted lines
> not i have:
> /home/apache/gitprojects/mydir.git
>
> created with: git init --base mydir.git
>
> Now, inside here, what should i do to create my projects:
>
> mkdir myproject1
> cd myproject1
> git init
> touch a.txt
> git add .
> git commit -m "1st commit"
>
> am i correct or not really?

You created "myproject1" somewhere you started "mkdir" in (perhaps in $HOME?) [*1*] and that project tracks a single file "a.txt"; you are correct if that was what you wanted to do.

The new repository "myproject1" doesn't have any relation to the bare repository at /home/apache/gitprojects/mydir.git/ you created earlier. The next steps I recommend new people are:

 (1) push into the public repository, by doing:
     cd myproject1
     git push /home/apache/gitprojects/mydir.git/ master
 (2) make sure push went correctly by trying to clone from there:
     cd ..
     mv myproject1 myproject1.old
     git clone /home/apache/gitprojects/mydir.git/ myproject1
 (3) check if the clone is what you expect
     diff myproject1.old/a.txt myproject1/a.txt
 (4) once satisfied, remove the old one
     rm -fr myproject1.old
And keep working in the myproject1 repository from there on.
[Footnote]

*1* If you started that "mkdir" somewhere else you may want to remove it and redo that step, especially if you did so inside that bare repository you created earlier, i.e. /home/apache/gitprojects/mydir.git directory. You don't want to have it there.

mysql.jorge@decimal.pt· Dec 28, 2009, 10:34 UTC · re: Junio C Hamano · lore

Re: Newbie to git

Show 6 quoted lines
> If you are addressing Andreas, why does your mail have:
> 
>     To: <git@vger.kernel.org>
>     Cc: <git@vger.kernel.org>
> 
> and no other addressee???
My error, sorry :)
Show 28 quoted lines
> You created "myproject1" somewhere you started "mkdir" in (perhaps in
> $HOME?) [*1*] and that project tracks a single file "a.txt"; you are
> correct if that was what you wanted to do.
> 
> The new repository "myproject1" doesn't have any relation to the bare
> repository at /home/apache/gitprojects/mydir.git/ you created earlier.
> The next steps I recommend new people are:
> 
>  (1) push into the public repository, by doing:
> 
>      cd myproject1
>      git push /home/apache/gitprojects/mydir.git/ master
> 
>  (2) make sure push went correctly by trying to clone from there:
> 
>      cd ..
>      mv myproject1 myproject1.old
>      git clone /home/apache/gitprojects/mydir.git/ myproject1
> 
>  (3) check if the clone is what you expect
> 
>      diff myproject1.old/a.txt myproject1/a.txt
> 
>  (4) once satisfied, remove the old one
> 
>      rm -fr myproject1.old
> 
> And keep working in the myproject1 repository from there on.

Thank you, i understood, i believe i really did. did that test and it's OK. But let me reask in another way:

I want to setup the git server, to accept new branch's created in a remote place that will be push'ed to it, please correct me, 'cause i'm doing something wrong and i don't know what yet.

- setup git server to run with:
/usr/lib/git-core/git-daemon --reuseaddr --syslog --export-all
--enable=receive-pack --verbose --base-path=/home/apache/gitprojects
- created directory /home/apache/gitprojects
- git init --bare /home/apache/gitprojects
- what will be my link on the remote? "git://192.168.1.206" just?
- From now on, how can I have access to push projects that exist on other
machine?

Sorry for the questions... they are newbie! Jorge,

Eugene Sajine· Dec 28, 2009, 16:51 UTC · re: mysql.jorge@decimal.pt · lore

Re: Newbie to git

On Mon, Dec 28, 2009 at 5:34 AM,  <mysql.jorge@decimal.pt> wrote:
Show 59 quoted lines
>> If you are addressing Andreas, why does your mail have:
>>
>>     To: <git@vger.kernel.org>
>>     Cc: <git@vger.kernel.org>
>>
>> and no other addressee???
>
> My error, sorry :)
>
>> You created "myproject1" somewhere you started "mkdir" in (perhaps in
>> $HOME?) [*1*] and that project tracks a single file "a.txt"; you are
>> correct if that was what you wanted to do.
>>
>> The new repository "myproject1" doesn't have any relation to the bare
>> repository at /home/apache/gitprojects/mydir.git/ you created earlier.
>> The next steps I recommend new people are:
>>
>>  (1) push into the public repository, by doing:
>>
>>      cd myproject1
>>      git push /home/apache/gitprojects/mydir.git/ master
>>
>>  (2) make sure push went correctly by trying to clone from there:
>>
>>      cd ..
>>      mv myproject1 myproject1.old
>>      git clone /home/apache/gitprojects/mydir.git/ myproject1
>>
>>  (3) check if the clone is what you expect
>>
>>      diff myproject1.old/a.txt myproject1/a.txt
>>
>>  (4) once satisfied, remove the old one
>>
>>      rm -fr myproject1.old
>>
>> And keep working in the myproject1 repository from there on.
>
> Thank you, i understood, i believe i really did. did that test and it's
> OK.
> But let me reask in another way:
>
> I want to setup the git server, to accept new branch's created in a remote
> place that will be push'ed to it, please correct me, 'cause i'm doing
> something wrong and i don't know what yet.
>
> - setup git server to run with:
> /usr/lib/git-core/git-daemon --reuseaddr --syslog --export-all
> --enable=receive-pack --verbose --base-path=/home/apache/gitprojects
>
> - created directory /home/apache/gitprojects
> - git init --bare /home/apache/gitprojects
>
> - what will be my link on the remote? "git://192.168.1.206" just?
> - From now on, how can I have access to push projects that exist on other
> machine?
>
> Sorry for the questions... they are newbie!
> Jorge,

Your /home/apache/gitprojects is a folder where your git repositories are supposed to be placed. Your Git repository = your project.

By running a git daemon the way you do - you say that you are going to serve all repositories from /home/apache/gitprojects.

Bare repo = repo without working copy - the one which contains only history and git objects (imagine it to be only .git folder from normal repo) Therefore for bare repos there is a naming convention so they have .git extension, while normal repo doesn't. So, myProject.git is server based bare repo, while myProject is a local repo.

Finally you have /home/apache/gitprojects/myProject.git

The URL to clone from there will be - should be shown to you by CGIT if you have everything correctly set up git://192.168.1.206/myProject.git

Hope that helps, Eugene

Jorge Bastos· Dec 28, 2009, 22:23 UTC · re: Eugene Sajine · lore

Re: Newbie to git

Show 18 quoted lines
> Your /home/apache/gitprojects is a folder where your git repositories
> are supposed to be placed.
> Your Git repository = your project.
> 
> By running a git daemon the way you do - you say that you are going to
> serve all repositories from /home/apache/gitprojects.
> 
> Bare repo = repo without working copy - the one which contains only
> history and git objects (imagine it to be only .git folder from normal
> repo) Therefore for bare repos there is a naming convention so they
> have .git extension, while normal repo doesn't. So, myProject.git is
> server based bare repo, while myProject is a local repo.
> 
> Finally you have /home/apache/gitprojects/myProject.git
> 
> The URL to clone from there will be - should be shown to you by CGIT
> if you have everything correctly set up
> git://192.168.1.206/myProject.git
Lets see if i understood:
my steps:

git init --bare /home/apache/gitbare cd /home/apache/gitprojects mkdir project cd project git init myproject.git

on gitweb, i see the project names in this format: "myproject.git/.git"

for example, for the git repo on git.kernel.org, it is shown as: "git/git.git"

shouldn't it appear in the same way here?

i have: $projectroot = "/home/apache/gitprojects/project/";

for CGIT, i have: repo.path=/home/apache/gitprojects/project/myproject.git

but it doesn't show nothing after i click it.

on the other hand, i cannot push changes via remote, after cloned the repository with:

git clone git://192.168.1.206/project/myproject.git
add some files

git add . git commit -m "aaaa" git push --tags "origin" master:master

and get:
error: unpack failed: unpack-objects abnormal exit
To git://192.168.1.206/project/myproject.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to
'git://192.168.1.206/project/myproject.git'
Failed

i feel i'm almost there but something is missing here... sorry my newbienest!

Shantanu Pavgi· Dec 28, 2009, 23:51 UTC · re: Jorge Bastos · lore

RE: Newbie to git

Jorge,
I remember having similar problem. I think it is with the user permissions. Check if the 'push-user' has read-write permissions on public repo. Check out  '--shared' option while initializing bare repo  (git-init --bare) or set appropriate permissions using chown/chmod. Hope this helps..

Thanks, Shantanu Pavgi.

________________________________________
From: git-owner@vger.kernel.org [git-owner@vger.kernel.org] On Behalf Of Jorge Bastos [mysql.jorge@decimal.pt]
Sent: Monday, December 28, 2009 4:23 PM
To: Eugene Sajine
Cc: Junio C Hamano; git@vger.kernel.org
Subject: Re: Newbie to git
Show 18 quoted lines
> Your /home/apache/gitprojects is a folder where your git repositories
> are supposed to be placed.
> Your Git repository = your project.
>
> By running a git daemon the way you do - you say that you are going to
> serve all repositories from /home/apache/gitprojects.
>
> Bare repo = repo without working copy - the one which contains only
> history and git objects (imagine it to be only .git folder from normal
> repo) Therefore for bare repos there is a naming convention so they
> have .git extension, while normal repo doesn't. So, myProject.git is
> server based bare repo, while myProject is a local repo.
>
> Finally you have /home/apache/gitprojects/myProject.git
>
> The URL to clone from there will be - should be shown to you by CGIT
> if you have everything correctly set up
> git://192.168.1.206/myProject.git
Lets see if i understood:
my steps:

git init --bare /home/apache/gitbare cd /home/apache/gitprojects mkdir project cd project git init myproject.git

on gitweb, i see the project names in this format: "myproject.git/.git"

for example, for the git repo on git.kernel.org, it is shown as: "git/git.git"

shouldn't it appear in the same way here?

i have: $projectroot = "/home/apache/gitprojects/project/";

for CGIT, i have: repo.path=/home/apache/gitprojects/project/myproject.git

but it doesn't show nothing after i click it.

on the other hand, i cannot push changes via remote, after cloned the repository with:

git clone git://192.168.1.206/project/myproject.git
add some files

git add . git commit -m "aaaa" git push --tags "origin" master:master

and get:
error: unpack failed: unpack-objects abnormal exit
To git://192.168.1.206/project/myproject.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to
'git://192.168.1.206/project/myproject.git'
Failed

i feel i'm almost there but something is missing here... sorry my newbienest!

Jorge Bastos· Dec 29, 2009, 12:11 UTC · re: Shantanu Pavgi · lore

RE: Newbie to git

> I remember having similar problem. I think it is with the user
> permissions. Check if the 'push-user' has read-write permissions on
public
> repo. Check out  '--shared' option while initializing bare repo 
(git-init
> --bare) or set appropriate permissions using chown/chmod. Hope this
helps..
Bingo!

Thank you, Jorge,

← back to recent threads