On Mon, Oct 24, 2011 at 02:42:34PM -0700, wkevin wrote:

> I have two local git repos which basically are the same.
> the first one is in fact only changed once in a while.
> I want that the changes in the first repo will be copied to the
> second repo.
> When I perform this copy/sync operation,  the second repo is known to
> be in the state of the first repo before last changes to the first
> repo.
> 
> Of course I can produce the list of changed files of the first repo
> by:
> git diff --name-only
> and then copy them one by one manually to the second repo.
> But this is a bit cumbersome.
> Is there some automatic way to do it ?
> with git, or maybe with rsync ?
Use Git.
To the repo which is to receive changes, add new remote pointing to the
first repo, like

$ git remote add source /path/to/the/first/remote's/work/tree

Then do

$ git fetch source $(git config --get remote.source.fetch)

which will bring all the branches from the source repo in, which you'll
be able to inspect using `git branch -a`.
Of course, you are able to bring only the specific branches, like using 
"refs/heads/foobranch:refs/remotes/source/foobranch" to fetch only the
"foobranch" and make it to appear as "remotes/source/foobranch" locally.
Of course, you could as well specify a different destination name,
say, if you're only interested in the remote master branch, you can just
use "refs/heads/master:refs/heads/thatmaster" to get the local branch
"thatmaster"--after merging its contents into the local master (see
below) you can just delete it.

As the last step, merge those new remote branches to your local
branches, like

$ git checkout master
$ git merge --ff source/master
...

Depending on what usage pattern is really wanted for these two
repositories, you might want to make some of your local branches to
track those remote branches.  To achieve this, you could do

$ git branch --track master source/master
...

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to