threads / discuss / 20901

git push stages original version on server

Subject: git push stages original version on server

## tl;dr

3 messages between Sep 11, 2009 and Sep 11, 2009.

replies: 2people: 3as markdown or json

Roald de Vries· Sep 11, 2009, 10:40 UTC · lore
Hi all,

There's a thing I don't understand: I have a repository on a server from/to which I pull/push. But when I push to it, and do a checkout on the server, the pushed changes are not visible. It appears that the changed file is added to the index on the server automatically. Why is this? It seems dangerous. If I do a commit on the server, the changes from the client will be lost.

There's also a thing I'm not sure exists: I use a git server/client setup for developing a website. I would like git-pushes to appear immediately online (without having to ssh to the server and checking out manually). Is this possible?

My questions are:
- Why does git work like this?
- Can I change its behaviour (if I still want that after the answer to  
the previous question)?
- How can I have git automatically checkout pushed changes on the  
server?
Thanks in advance.
Kind regards,
Roald
Paolo Bonzini· Sep 11, 2009, 11:09 UTC · re: Roald de Vries · lore

Re: git push stages original version on server

Pushing to a non-bare repository is discouraged.
> - How can I have git automatically checkout pushed changes on the server?

I think you could in principle add a hook that does the "git checkout" or "git reset --hard $(git symbolic-ref HEAD)", but I suggest pushing to a bare repository and have the hook trigger a "git pull" elsewhere.

Paolo
Mikael Magnusson· Sep 11, 2009, 11:11 UTC · re: Roald de Vries · lore

Re: git push stages original version on server

2009/9/11 Roald de Vries <rdv@roalddevries.nl>:
Show 25 quoted lines
> Hi all,
>
> There's a thing I don't understand: I have a repository on a server from/to
> which I pull/push. But when I push to it, and do a checkout on the server,
> the pushed changes are not visible. It appears that the changed file is
> added to the index on the server automatically. Why is this? It seems
> dangerous. If I do a commit on the server, the changes from the client will
> be lost.
>
> There's also a thing I'm not sure exists: I use a git server/client setup
> for developing a website. I would like git-pushes to appear immediately
> online (without having to ssh to the server and checking out manually). Is
> this possible?
>
> My questions are:
> - Why does git work like this?
> - Can I change its behaviour (if I still want that after the answer to the
> previous question)?
> - How can I have git automatically checkout pushed changes on the server?
>
> Thanks in advance.
>
> Kind regards,
>
> Roald
http://git.or.cz/gitwiki/GitFaq#Whywon.27tIseechangesintheremoterepoafter.22gitpush.22.3F
-- 
Mikael Magnusson

← back to recent threads