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

Re: git svn branch tracking + ignore paths

From
Avery Pennarun <apenwarr@gmail.com>
Date
Oct 28, 2009, 16:00 UTC
Message-ID
<32541b130910280900p421e69b1nbcd8dcfa211521ac@mail.gmail.com>
In-Reply-To
<19979334-07EB-48CA-8E62-4ECC5E1FA51C@gmail.com>
On Wed, Oct 28, 2009 at 1:59 AM, Lachlan Deck <lachlan.deck@gmail.com> wrote:
Show 19 quoted lines
> On 28/10/2009, at 4:20 PM, Avery Pennarun wrote:
>> So which are the files you don't want to import from trunk?  It
>> doesn't sound like there are any... so it's getting simpler already.
>
> There are. I've currently (as a workaround) done the following within the
> main branch:
> add the following to .git/info/exclude
> .settings
> target
> .classpath
> .project
>
> The last two of these has no effect of course because .project and
> .classpath files already exist -- and thus are marked as modified. So I'm
> currently doing a git stash && git svn rebase && git svn dcommit && git
> stash pop
>
> I'm also wanting to exclude 'lib' folders from trunk (as these are not
> needed).

The problem is that as your branch diverges from what you *actually* want to commit, it becomes exponentially more complicated to figure out what you *do* want to commit.

Note that if you're planning to share your git project with other people anyway, then you have an additional problem: you're using git svn rebase, which is almost useless for sharing with other people (other than through svn, of course), for the same reason any git rebase is.

One option you have is to maintain two branches:
1. (git-svn) The git-svn trunk, which contains only stuff you want upstream
2. (master) Your live branch, which contains everything from (1) plus
your local customizations.
When you want to fetch from svn, you do this:
  git checkout master
  git svn fetch git-svn
  git merge git-svn
When you want to push to svn, you do this:
  git checkout git-svn
  git merge --squash --no-commit master
    (now undo your local customizations)
  git commit
  git svn dcommit
  git checkout master
  git merge git-svn

Note that master never gets rebased, only merged. If you can write a simple script for "undo your local customizations" - such as reverting a particular commit, for example - then you can put the above in a shell script and it should work fine most of the time.

Good luck.
Avery
Previous: Lachlan DeckNext: Lachlan Deck
Message 6 of 7 in “git svn branch tracking + ignore paths”
  1. Lachlan DeckOct 27, 2009
  2. Avery PennarunOct 27, 2009
  3. Lachlan DeckOct 28, 2009
  4. Avery PennarunOct 28, 2009
  5. Lachlan DeckOct 28, 2009
  6. Avery PennarunOct 28, 2009
  7. Lachlan DeckOct 29, 2009

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.