Domanda

I'm a bit of a beginner in git, mainly relying on GUI tools like Source Tree, so bear with me, please!

In our git repo, we have multiple products that rely on a very similar core codebase. We achieve this by having a branch per product. When we first started development, we hadn't established this as a workflow, so our branch history looks a bit like this:

 master
   |
B  |  C
 \ | /
  \|/
   |
   |  A
   | /
   |/
   2
   |
   |
   1
   |
   |

A, B, and C are product-specific branches, with A being our first product for a client.

The problem

Unfortunately, around point (1) we were already working on A, and had already started to commit a large number of .png files (around 100MB worth), but didn't think to branch it off as a separate project yet. I've tried pruning out these large files from the repo in B and C (as well as the master branch), but of course they're still in the git commit history between points (1) and (2).

So, is there any way I could re-write the history, so that branch A actually starts at point 1, and move all files specific to that product into that branch? Thankfully it should be pretty easy to filter out the files associated with product A, since they're mostly in a separate directory.

Theoretically, the master branch would only need to be ~10MB since it would mainly consist of code, meaning that people could check out only a specific product branch, and only download the files from github that they actually need.

Thanks!

Edit: Note, this is a similar question: git: Split history of some files into a separate branch

È stato utile?

Soluzione

First, backup!

Then, do this:

git filter-branch -f --prune-empty --tree-filter 'rm -rf PATH/TO/FILE-OR-FOLDER' HEAD

And then

git gc --aggressive

Via http://www.simplicidade.org/notes/archives/2009/04/merging_two_unr.html

Altri suggerimenti

The following should do the trick:

git checkout A
git rebase 2 --onto 1
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top