threads / discuss / 17274

Newbie Query

Subject: Newbie Query

## tl;dr

11 messages between Jan 20, 2009 and Jan 21, 2009.

replies: 10people: 8as markdown or json

Chris Willard· Jan 20, 2009, 19:19 UTC · lore
Hello All,
I am having a go at using git and need a bit of help.

I have git installed on my laptop and on my pc. I created some files on the pc then used git close via ssh to put them on my laptop - all OK so far!

I then modified the files, added them, commited the changes and then used git push to put them on the PC - still no problems.

Both systems show the commits but the PC does not have the latest version of the files. Git status on the PC shows the file as changed but commiting give an error when pushing from the laptop.

I assume that I need to run a command on the PC to get both systems the same. Is it a reset or something else?

Regards,
Chris
-- 
... "Even the gods did not spring into being overnight." Spock

--
This message was scanned by ESVA and is believed to be clean.
Tomas Carnecky· Jan 20, 2009, 20:00 UTC · re: Chris Willard · lore

Re: Newbie Query

On 01/20/2009 08:19 PM, Chris Willard wrote:
Show 17 quoted lines
> Hello All,
>
> I am having a go at using git and need a bit of help.
>
> I have git installed on my laptop and on my pc. I created some files
> on the pc then used git close via ssh to put them on my laptop - all
> OK so far!
>
> I then modified the files, added them, commited the changes and then
> used git push to put them on the PC - still no problems.
>
> Both systems show the commits but the PC does not have the latest
> version of the files. Git status on the PC shows the file as changed
> but commiting give an error when pushing from the laptop.
>
> I assume that I need to run a command on the PC to get both systems
> the same. Is it a reset or something else?
http://git.or.cz/gitwiki/GitFaq#non-bare
tom
Sverre Rabbelier· Jan 20, 2009, 20:16 UTC · re: Chris Willard · lore

Re: Newbie Query

Heya,
On Tue, Jan 20, 2009 at 20:19, Chris Willard <chris@thewillards.co.uk> wrote:
Show 6 quoted lines
> I then modified the files, added them, commited the changes and then
> used git push to put them on the PC - still no problems.
>
> Both systems show the commits but the PC does not have the latest
> version of the files. Git status on the PC shows the file as changed
> but commiting give an error when pushing from the laptop.

Please read http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73 and let us know if you have any other problems.

-- 
Cheers,

Sverre Rabbelier
Reece Dunn· Jan 20, 2009, 20:17 UTC · re: Chris Willard · lore

Re: Newbie Query

2009/1/20 Chris Willard <chris@thewillards.co.uk>:
Show 11 quoted lines
> Hello All,
>
> I then modified the files, added them, commited the changes and then
> used git push to put them on the PC - still no problems.
>
> Both systems show the commits but the PC does not have the latest
> version of the files. Git status on the PC shows the file as changed
> but commiting give an error when pushing from the laptop.
>
> I assume that I need to run a command on the PC to get both systems
> the same. Is it a reset or something else?

So IIUC running 'git log' on the machine you pushed the changes to, you can see the checkin you made on the machine you made the change on? You need to run 'git checkout' on the machine you pushed to, to tell git that you want these files. This is a safety feature, since someone may be working on the files on that machine locally, and so doesn't want them being overwritten by your push.

You may find the documentation (http://git-scm.com/documentation) useful, especially http://www.kernel.org/pub/software/scm/git/docs/everyday.html which has your scenario under "Push into another repository. ".

If you want someone to take some changes you made, it is recommended to let them know so that they can run 'git pull' or 'git fetch' to get your changes (performing a merge or rebase as desired). This means that they control when they get the updates and what they want to do with them.

If you are committing the files to a shared public repository (e.g. a
central repository, or build server repository), a pussible approach
is to create that as a "bare" repository (one with just the contents
of the .git folder - i.e. it does not have any files checked out). You
can do this by running:
    git clone --bare source/git/path/project project.git
you can then clone from this:
    git clone my/shared/project.git
and push any changes to it as normal.

The build server can then do a 'git pull' to get the new changes from that repository.

You can keep it setup like you currently have (assuming that where you
are pushing to is a shared repository), and do:
    git checkout HEAD
before you run a build (assuming this is the repository that you are
using for your builds). The advantage of a bare repository is that it
will take up less space, and using a different (cloned) repository for
performing builds keeps the main repository clean.

One of the great things about git is that you can customise it to fit different workflows.

HTH,
- Reece
Nicolas Morey-Chaisemartin· Jan 20, 2009, 21:07 UTC · re: Reece Dunn · lore

Re: Newbie Query

Reece Dunn a écrit :
Show 12 quoted lines
>
> If you are committing the files to a shared public repository (e.g. a
> central repository, or build server repository), a pussible approach
> is to create that as a "bare" repository (one with just the contents
> of the .git folder - i.e. it does not have any files checked out). You
> can do this by running:
>     git clone --bare source/git/path/project project.git
> you can then clone from this:
>     git clone my/shared/project.git
> and push any changes to it as normal.
>
>   
Hi,

I did the rookie mistkae on the central server to create the main reposity in non-bare mode. So i need to checkout the HEAD revision each time I push. Is there a cleaner way to convert a non-bare git repo into a bare repo than cloning it? My repo have a lot of remote branch registered, and cloning them to a new bare repo mean I'll have to add all those remote branches again (except if there is another trick here I don't know about).

Regards
Nicolas
Boyd Stephen Smith Jr.· Jan 20, 2009, 21:34 UTC · re: Nicolas Morey-Chaisemartin · lore

Re: Newbie Query

On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
Show 8 quoted lines
>I did the rookie mistkae on the central server to create the main
>reposity in non-bare mode. So i need to checkout the HEAD revision each
>time I push.
>Is there a cleaner way to convert a non-bare git repo into a bare repo
>than cloning it?
>My repo have a lot of remote branch registered, and cloning them to a
>new bare repo mean I'll have to add all those remote branches again
>(except if there is another trick here I don't know about).

Well, if you can make sure no one is pushing into the repo for a bit: clone it and replace the original with a symlink to new, bare one. Your clients will be able to use the same URL, so they should be happy. (I haven't tried this, but it should work.)

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
Nicolas Morey-Chaisemartin· Jan 20, 2009, 21:46 UTC · re: Boyd Stephen Smith Jr. · lore

Re: Newbie Query

Boyd Stephen Smith Jr. a écrit :
Show 17 quoted lines
> On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
>   
>> I did the rookie mistkae on the central server to create the main
>> reposity in non-bare mode. So i need to checkout the HEAD revision each
>> time I push.
>> Is there a cleaner way to convert a non-bare git repo into a bare repo
>> than cloning it?
>> My repo have a lot of remote branch registered, and cloning them to a
>> new bare repo mean I'll have to add all those remote branches again
>> (except if there is another trick here I don't know about).
>>     
>
> Well, if you can make sure no one is pushing into the repo for a bit: clone it 
> and replace the original with a symlink to new, bare one.  Your clients will 
> be able to use the same URL, so they should be happy.  (I haven't tried this, 
> but it should work.)
>   

Well I know there are solutions to convert it to a bare repo. I was just wondering if there was a "clean" one which really converts the repo to a bare one and not create a copy which is bare. I don't know how bare/non-bare is managed but I guess both types of repo are not differing by much, so it'd be great to have a function to convert from one to another.

Boyd Stephen Smith Jr.· Jan 20, 2009, 22:24 UTC · re: Nicolas Morey-Chaisemartin · lore

Re: Newbie Query

On Tuesday 2009 January 20 15:46:47 Nicolas Morey-Chaisemartin wrote:
Show 6 quoted lines
>Boyd Stephen Smith Jr. a écrit :
>> On Tuesday 2009 January 20 15:07:55 Nicolas Morey-Chaisemartin wrote:
>>> I did the rookie mistkae on the central server to create the main
>>> reposity in non-bare mode.
>>> Is there a cleaner way to convert a non-bare git repo into a bare repo
>>> than cloning it?
No.
Show 12 quoted lines
>>> My repo have a lot of remote branch registered, and cloning them to a
>>> new bare repo mean I'll have to add all those remote branches again
>>> (except if there is another trick here I don't know about).
>>
>> Well, if you can make sure no one is pushing into the repo for a bit:
>> clone it and replace the original with a symlink to new, bare one.  Your
>> clients will be able to use the same URL, so they should be happy.  (I
>> haven't tried this, but it should work.)
>
>Well I know there are solutions to convert it to a bare repo.
>I was just wondering if there was a "clean" one which really converts
>the repo to a bare one and not create a copy which is bare.

The clone *is* a way to convert, with the added advantage of not trashing the original during the conversion, by putting the results in a different location. In fact, it's probably *cleaner* than any convert-in-place.

>I don't know how bare/non-bare is managed but I guess both types of repo
>are not differing by much, so it'd be great to have a function to
>convert from one to another.

I couldn't tell you all the differences, but I don't think there are many either.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
Jeff King· Jan 20, 2009, 23:51 UTC · re: Nicolas Morey-Chaisemartin · lore

Re: Newbie Query

On Tue, Jan 20, 2009 at 10:46:47PM +0100, Nicolas Morey-Chaisemartin wrote:
> Well I know there are solutions to convert it to a bare repo.
> I was just wondering if there was a "clean" one which really converts
> the repo to a bare one and not create a copy which is bare.

It has been a long time since I have done this. It used to be that you could simply "mv foo/.git foo.git" and be done with it. These days I think you would also need "git config core.bare true". But I haven't actually tested it recently.

You may also want to tweak other config settings (e.g., bare repositories do not generally have reflogs turned on, but non-bare do).

-Peff
Johannes Schindelin· Jan 21, 2009, 00:05 UTC · re: Jeff King · lore

Re: Newbie Query

Hi,
On Tue, 20 Jan 2009, Jeff King wrote:
Show 10 quoted lines
> On Tue, Jan 20, 2009 at 10:46:47PM +0100, Nicolas Morey-Chaisemartin wrote:
> 
> > Well I know there are solutions to convert it to a bare repo.
> > I was just wondering if there was a "clean" one which really converts
> > the repo to a bare one and not create a copy which is bare.
> 
> It has been a long time since I have done this. It used to be that you 
> could simply "mv foo/.git foo.git" and be done with it. These days I 
> think you would also need "git config core.bare true". But I haven't 
> actually tested it recently.

Yep, you need to set that option. At least if you initialized your repository with anything newer than v1.5.0-rc1~3^2~2.

Ciao, Dscho

Chris Willard· Jan 21, 2009, 14:31 UTC · re: Chris Willard · lore

Re: Newbie Query

On Tue, 20 Jan 2009, Chris Willard wrote:
> Hello All,
> 
> I am having a go at using git and need a bit of help.
[snip]

Thanks for all the tips - I used "git-reset --hard" to solve my problem.

Regards,
Chris
-- 
-----------(  "The Batman play seemed important to Crow." --  )------------
-----------(                   Mike Nelson                    )------------
Chris -----(                                                  )---- Willard
                             Htag.pl 0.0.23

--
This message was scanned by ESVA and is believed to be clean.

← back to recent threads