threads / discuss / 23327

Git-Automerge

Subject: Git-Automerge

## tl;dr

3 messages between Apr 4, 2010 and Apr 4, 2010.

replies: 2people: 3as markdown or json

Nico Schümann· Apr 4, 2010, 16:47 UTC · lore
Dear Git people,

after having been convinced by Linus Torvald's talk on git, I've been using it for some days now.

But there is one thing that just does not get into my mind, or maybe I am just thinking too complicated.

What I have is a productive system, let's call it MASTER and my development machine, call it ME.

Now I made a copy of the MASTER tree by $ git pull me@master:/path/to/stuff

And did some changes: $ nano -w blablabla

Then I commited: $ git commit

Everything fine until now.

What I want now are the changes to apper on the MASTER server, so I say $ git push

But the changes do not appear on the master server. I have to type

# git reset --hard      or # git checkout -f in order to make the changes appear. Since I do not want to login onto that MASTER machine every time, what command do I miss on my developer machine?

Thanks in advantage, Nico

Matthieu Moy· Apr 4, 2010, 16:53 UTC · re: Nico Schümann · lore

Re: Git-Automerge

Nico Schümann <nico.schuemann@googlemail.com> writes:
> But the changes do not appear on the master server. I have to type
>
> # git reset --hard      or
> # git checkout -f

You pushed to a checked-out branch. You shouldn't do that, and recent Git prevent you from doing it.

The reason Git cannot do the merge automatically is that a merge can go wrong, and may require a human interaction to resolve conflicts. Hence, "push" never does a merge, only "pull" (and obviously local merge) will do.

You can do
client-machine$ git push URL-OF-SERVER HEAD:tmp

to push your current HEAD to a branch named "tmp" on the server, and then

server-machine$ git merge tmp

to merge the changes in the current branch of the server. Another option is to have a bare repository reachable from both machines, and both machine would push/pull to this repository (just like you'd do with a centralized version control system).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Ramkumar Ramachandra· Apr 4, 2010, 17:00 UTC · re: Nico Schümann · lore

Re: Git-Automerge

Hi,

On Sun, Apr 4, 2010 at 10:17 PM, Nico Schümann <nico.schuemann@googlemail.com> wrote:

Show 6 quoted lines
> $ git push
>
> But the changes do not appear on the master server. I have to type
>
> # git reset --hard      or
> # git checkout -f

git-push only propagates history and updates refs. It doesn't touch files in the working tree. I suspect you're pushing to a non-bare remote. Please see --bare option in git-init (1) and this FAQ [0] on the Git Wiki for more.

[0] https://git.wiki.kernel.org/index.php/GitFaq#Why_won.27t_I_see_changes_in_the_remote_repo_after_.22git_push.22.3F
-- Ram

← back to recent threads