git/list[1] front-page[2] threads[3] people[4] search[5] about
 

finding the right remote branch for a commit

From
MKmartin f krafft <madduck@madduck.net>
Date
Jul 10, 2007, 14:49 UTC
Message-ID
<20070710144907.GA324@piper.oerlikon.madduck.net>
Dear list,

I am trying to figure out a way to store ~/.etc in git. With SVN, I would have a .etc repository for each machine, which would use svn:externals to reference locations of the various subdirectories, which SVN would then pull and assemble. Thus, my ~/.etc might be

  ~/.etc
  ~/.etc/ssh [svn+ssh://svn.madduck.net/priv/etc/ssh]
  ~/.etc/vim [svn+ssh://svn.madduck.net/pub/etc/vim]
  ...

With git, I am now considering using remote branches for this kind of stuff. So I'll have a repository for my ssh config and a repository for my vim config, and so on.

The idea then is to create another repository for each machine and to register the remote tracking branches there in much the same way that I used svn:externals previously (and with the added benefit that I don't have to stay within subdirectories).

Thus, the vim repository might look like this:
  .etc/
  |-- vim/
  |   `-- rc.vim
  `-- .vimrc -> .etc/vim/rc.vim
and the ssh configuration might be
  .etc/
  |-- ssh/
  |   |-- config
  |   `-- authorized_keys
  `-- .ssh -> .etc/ssh/

My theory is that merging all those remotely tracked branches into a local repo populates my home directory, and bringing it up to the latest version is as simple as:

  git remote update
  git branch -r | xargs git merge   # any way to just merge all remote branches?
So far so good, this seems to work just fine.

Right now I am trying to figure out how to push updates back to the central store so that other machines who "subscribe" to a given branch can receive the updates.

For instance, I may have made a change to ~/.vimrc and to ~/.ssh/config and committed each to the machine-local repository. What I need now is a way to tell me

  (a) which commits are local and have not been merged from a remote
      tracking branch. If I actually want to keep commits local,
      e.g. because of changes only applicable to this one machine,
      I can move them to a local branch and rebase that whenever the
      remotes change.
  (b) which commits should be pushed where. This is a bit of
      a strange one it may seem, but in my case, remote branches are
      orthogonal and never touch the same file. Thus, each file
      belongs to one remote branch. How can I determine which one?
      Or even better, how could I push all my local commits to the
      respective remotes?

Thanks for any comments, and sorry to be cluttering the list with my newbie stuff...

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck
 
spamtraps: madduck.bogus@madduck.net
 
"moderation is a fatal thing. enough is as bad as a meal. more than
 enough is as good as a feast."
                                                        -- oscar wilde
Next: Johannes Schindelin
Message 1 of 7 in “finding the right remote branch for a commit”
  1. martin f krafftJul 10, 2007
  2. Johannes SchindelinJul 11, 2007
  3. martin f krafftJul 12, 2007
  4. Jakub NarebskiJul 12, 2007
  5. Matthias LederhoferJul 15, 2007
  6. Johannes SchindelinJul 15, 2007
  7. Matthias LederhoferJul 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.