views:

27

answers:

1

My repository looks like this.

v1 - A - B - C ...

where the commit v1 represents the contents of upstream-project-foo-0.9.8.tar.gz and the commits A, B ... are my modifications.

The goal is to upgrade my copy of upstream-project and port the commits A, B, C ... to it.

How do I get a new version of the upstream-project tarball into my git repository as another branch? Or should I consider making a second git repository?

+1  A: 

create a new branch from v1 and extract the new version there.

git checkout -b upstream <v1>
tar -xzvf newversion.tar.gz
git add -A
git commit

You can then merge the changes between versions into your main branch where your updates are.

git checkout master
git merge upstream

You may also want to create a branch off of C (or whatever your latest version is) to merge the updates and then merge the third branch back into your master when you're done.

bemace
You probably want to `git rm -r .` before extracting the tarball (so that pathnames that existed in the *v1* commit but are not present in the new tarball (i.e. deleted/renamed files) do not persist in the *upstream* branch).
Chris Johnsen
@Chris my understanding is that add -A covers that per this post: http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add
bemace
Image two tarballs: `oldversion.tar.gz` has files `a`, and `b`; `newversion.tar.gz` has files `a`, and `c` (no `b`). If you just unpack “new” atop “old” you will have both `b` and `c`. You need to clean out anything that is in “old”, but is not in “new”. The easiest way to do this is to delete everything that was in “old”, then unpack (and add, via `-A`) anything that came with “new”. `git add -A` will remove from the index pathnames that do not exist in the working tree, but it can not identify the pathnames that were in “old” but not in “new” if you just unpack the later over the former.
Chris Johnsen