swcarpentry / DEPRECATED-bc

DEPRECATED: This repository is now frozen - please see individual lesson repositories.
Other
299 stars 383 forks source link

Extract history of novice Python lesson #877

Closed gvwilson closed 9 years ago

gvwilson commented 9 years ago

Work in progress: https://github.com/aaren/swc-novice-python/

aaren commented 9 years ago

Here are the commands that I used:

git clone https://github.com/swcarpentry/bc
cd bc

# filter out the novice/python directory into a new branch 
# 'novice-python-history'
git checkout -b novice-python-history
git filter-branch --subdirectory-filter novice/python --prune-empty -f

# attach missed older history (from bc reorgs)
# https://github.com/wking/swc-modular-shell/issues/3
# (because lesson now in novice/python used to be in python/novice)

# goto the commit before the reorg
git checkout -b python-novice b8c7dc3^
# move python/novice to root and rewrite all commits accordingly
git filter-branch --subdirectory-filter python/novice --prune-empty -f

# now rebase to add this to the history
git checkout novice-python-history
ORPHAN_COPY_COMMIT=$(git rev-parse 'HEAD^{/Reorganizing material}')
git rebase -p --onto python-novice "${ORPHAN_COPY_COMMIT}"

# delete the temp branch
git branch -D python-novice

Now you should have a branch in bc called 'novice-python-history` that contains the history of only the novice python lesson, with all of the files in the top level.

Now we create a new repo and pull into it from this branch:

mkdir swc-novice-python
cd swc-novice-python
git init
git remote add bc ../bc
git pull bc novice-python-history
willingc commented 9 years ago

@aaren You are a git guru :cake:

You might consider making this a gist. It's helpful to others beyond swcarpentry :)

aaren commented 9 years ago

@willingc thank you :) but credit goes mostly to @wking https://github.com/wking/swc-modular-shell/issues/3

willingc commented 9 years ago

@aaren and @wking You both are git gurus :cake: :cake:

aaren commented 9 years ago

@wking any ideas on the easy way to transfer new (and relevant) commits from the bc repo to the extracted history, without repeating all of the steps?

i.e. say there are two new commits that touch python to bc:gh-pages - how would I do the filter-branch on only these two commits and add them on top of my extracted python history? I can't get my head around it.

tomwright01 commented 9 years ago

Hi Aaren, I had a similar issue (I think) with the sql history. I ended up 'cherry picking' the commits I was interested in. See the last few comments in this issue thread. https://github.com/tomwright01/swc-modular-sql/issues/3

On Mon, 2014-11-24 at 07:44 -0800, aaren wrote:

@wking any ideas on the easy way to transfer new (and relevant) commits from the bc repo to the extracted history, without repeating all of the steps?

i.e. say there are two new commits that touch python to bc:gh-pages - how would I do the filter-branch on only these two commits and add them on top of my extracted python history? I can't get my head around it.

— Reply to this email directly or view it on GitHub.

wking commented 9 years ago

On Mon, Nov 24, 2014 at 07:44:19AM -0800, aaren wrote:

@wking any ideas on the easy way to transfer new (and relevant) commits from the bc repo to the extracted history, without repeating all of the steps?

As @tomwright01 says, cherry-picking is the way to go.

aaren commented 9 years ago

So from my novice-python-history branch in my bc repo, I do

git cherry-pick <commit-hash-from-new-commit>

and this will auto-magically translate the commit so that it applies to the python files that are now in the root directory?

aaren commented 9 years ago

@wking @tomwright01 I tested and verified for myself: cherry-pick works auto-magically. Thanks :)

tomwright01 commented 9 years ago

Thats my understanding, however it won't capture the actual merge. I ended up creating another branch from my working branch, cherry picking the commits, then merging the new branch back to the old branch forcing the author name, email and date from the original merge commit.

On Mon, 2014-11-24 at 08:04 -0800, aaren wrote:

So from my novice-python-history branch in my bc repo, I do

git cherry-pick

and this will auto-magically translate the commit so that it applies to the python files that are now in the root directory?

— Reply to this email directly or view it on GitHub.

wking commented 9 years ago

Can this be closed now that we have https://github.com/swcarpentry/python-novice-inflammation?