git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Newbie problem
@ 2007-07-28  7:20 Insitu
  2007-07-28  8:01 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Insitu @ 2007-07-28  7:20 UTC (permalink / raw)
  To: git

Hello, 
I am new to git and gave it a try to version my home dir and
synchronize it between two machines. It works but I think I did some
mistakes in my setup which make its usability non optimal: 
 - push/pull operations need remote address
 - I didn't set up any branch

Here is what I did (lap is for operations on laptop, pc on desktop):
lap> git init
lap> git add ...
lap> git commit ...
lap> scp .git pc:
lap> mv .git git-init
pc> git checkout .
pc> git commit ...
lap> git clone  -n --bare --reference git-init/  ssh://pc/~/.git
lap> git checkout .
lap> git add ...
lap> git commit

Now, I want to be able to do:
lap> git push
or
lap> git pull

instead of 
lap> git push ssh://pc/~/.git

I think I need to reconfigure my remote branches/origin on laptop but
don't want ot break everything.

Help appreciated,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Newbie problem
  2007-07-28  7:20 Newbie problem Insitu
@ 2007-07-28  8:01 ` Junio C Hamano
  2007-07-28  8:50   ` Insitu
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-07-28  8:01 UTC (permalink / raw)
  To: Insitu; +Cc: git

Insitu <abailly@oqube.com> writes:

> Now, I want to be able to do:
> lap> git push
> or
> lap> git pull
>
> instead of 
> lap> git push ssh://pc/~/.git
>
> I think I need to reconfigure my remote branches/origin on laptop but
> don't want ot break everything.

The necessary syntax and configuration files are all documented
fairly detailed in the manual pages, but it is a tad hard to
know where to look:

    http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html
    http://www.kernel.org/pub/software/scm/git/docs/git-push.html
    http://www.kernel.org/pub/software/scm/git/docs/git-config.html

If you use recent enough git (post 1.5.0), the recommended way
to keep two boxes in sync is:

On mothership box, in .git/config:

 [remote "origin"]
     url = satellite:.git/
     fetch = +refs/heads/*:refs/remotes/origin/*
     push = refs/heads/*:refs/remotes/origin/*
 [branch "master"]
     remote = origin
     merge = refs/heads/master

On satellite laptop, in .git/config:

 [remote "origin"]
     url = mothership:.git/
     fetch = +refs/heads/*:refs/remotes/origin/*
     push = refs/heads/*:refs/remotes/origin/*
 [branch "master"]
     remote = origin
     merge = refs/heads/master

Then, whenever you start working on the satellite:

	$ git pull

which, while you are on "master" branch, would use 'origin' as
the default remote (thanks to branch.master.remote configuration),
store the copy of mothership's branches in refs/remotes/origin/,
and merges the "master" branch obtained from the mothership to
your "master" branch on the satellite [*1*].  

When you are done working on the satellite:

	$ git push

will push to "origin" by default, which would push all your
branches (thanks to remote.origin.push configuration) to
mothership's refs/remotes/origin/.

When you go back to the mothership, your work done on the
satellite are already pushed into the refs/remote/origin/
tracking branches, so you can merge them in (you can do this
after shutting down your satellite laptop, which is the beauty
of this setup):

	$ git merge origin/master

to merge in the changes you did on the satellite.


[Footnote]

*1* If you prefer to keep a straight history, you may want to
    fetch+rebase instead of pull which is a fetch+merge, in
    which case this step will be:

	$ git fetch
        $ git rebase origin/master

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Newbie problem
  2007-07-28  8:01 ` Junio C Hamano
@ 2007-07-28  8:50   ` Insitu
  0 siblings, 0 replies; 3+ messages in thread
From: Insitu @ 2007-07-28  8:50 UTC (permalink / raw)
  To: git

Junio C Hamano <gitster@pobox.com> writes:

>
>  [remote "origin"]
>      url = satellite:.git/
>      fetch = +refs/heads/*:refs/remotes/origin/*
>      push = refs/heads/*:refs/remotes/origin/*
>  [branch "master"]
>      remote = origin
>      merge = refs/heads/master
>
> On satellite laptop, in .git/config:
>
>  [remote "origin"]
>      url = mothership:.git/
>      fetch = +refs/heads/*:refs/remotes/origin/*
>      push = refs/heads/*:refs/remotes/origin/*
>  [branch "master"]
>      remote = origin
>      merge = refs/heads/master
>

Thanks a lot for all these details ! 

Yes, I also find Git very well
documented (maybe too much docuemented :) )  and could have come to
the settings with info from the various man pages. But much less
quickly of course.

My question is: can I do this right now that my repositories are up
and running ? 

Regards,
-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-28  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-28  7:20 Newbie problem Insitu
2007-07-28  8:01 ` Junio C Hamano
2007-07-28  8:50   ` Insitu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).