Domanda

desidero suddividere moduli distribuiti con una maggiore applicazione in moduli separati e mantenere la capacità di tirare da monte.

Quindi questo è più complessa di quanto Staccare sottodirectory in separata Git repository . Io non solo ho utilizzati git-filter-branch una volta, ma vuole mantenere la capacità di tirare le modifiche a monte dopo che ho fatto (ea monte non ha).

È sufficiente eseguire nuovamente git-filter-branch sulla storia completa da monte ora tra cui il nuovo non commit trovato nella mia storia riscritta non è un'opzione come ci sono centinaia di moduli per la quale devo fare questo e il numero di commit è sempre vicino a 100.000.

Sono indovinando si tratta di limitare la storia ai soli nuovi commit, riscrivere quelle e poi aggiungendo dopo il già riscritto impegna, ma non sono sicuro come fare questo -. E forse v'è un approccio migliore

Sarebbe bello se potessero essere preservate anche rami e tag, ma questo non è assolutamente necessario e se si complica le cose mi sarebbe in realtà preferirebbe perdere quelli.

È stato utile?

Soluzione

Per la prima rebase fare questo:

git checkout -b rebased master
git filter-branch --some-filter
git tag rebased-done master

E per "fondere" in seguito impegna:

# Create a tempory branch and rebase it's tail use 'rebase-done~'
# and not 'rebase-done' because some filters (like --index-filter)
# require this, others might not.
git checkout -b rebased-tail master
git filter-branch -f --some-filter -- rebased-done~..HEAD

# Get the commit in branch 'rebased' corresponding to tag 'rebase-done'
# (which tags a commit in 'master' not 'rebased').  Depending on your
# situation you might have to determine this commit differently (in my
# use case I am absolutely sure that there is never a commit with the
# same author date - if that doesn't work you might want to compare
# commit messages).
start_time=$(git show --quiet --pretty=%at rebased-done)
start_hash=$(
git log --reverse --pretty="%H %at" rebased_tail |
while read hash time
do
    [ "$time" = "$start_time" ] && echo $hash && break
done
)

# Finally apply the rebased commits.
git checkout rebased
git format-patch -k --stdout $start_hash..rebased-tail | git am -k
git branch -D rebased-tail
git tag -f rebased-done master
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top