Re: [git-users] Re: Creating a step-by-step tutorial

2011-01-05 Thread Thomas Ferris Nicolaisen
You use a temporary branch for creating the commits that you want to inject 
into earlier steps your tutorial. In git you can inject older commits by 
using rebase. This is a tad complicated, but I just spent some minutes 
figuring it out so might as well paste it :)

  E---F---G  topicA
 /
A---B---C---D  master

How can I inject topicA into master before B? So I get:

A---E'---F'---G'---B'---C'---D'  master

So, check out topicA branch. We'll first wind it back to (the tag) A in 
master, and play our commits E-F-G on top of that:

> git rebase --onto A master

And now we replay the commits in master which are not in topicA:

> git rebase --onto topicA topicA master

Now, the result is in the fix-step-1 branch, so you can remove master and 
rename the branch to be master instead.

*A much simpler approach* is to just work and commit normally in master, and 
then rewrite history with git rebase --interactive. This provides you with a 
really handy way of moving commits backwards in history, squashing them 
together with other commits, editing old commits, etc.

Note that you should never rebase/rewrite history in a published repository.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Creating a step-by-step tutorial

2011-01-04 Thread Karel Vervaeke
Then I would need to rebuild the repository when I want to make change to
one of the steps. The point of using branches
is that I can make changes to each step afterwards, and have those changes
propagate through to later steps (by merging).

I guess I could use tags on a single branch to mark different steps, but
when I want to inject a change at one of the steps, I would need a branch
anyway.

This guy seems to have done what I want (more or less):
http://kevin.deldycke.com/2010/06/git-commit-history-reconstruction/
The webpage seems down, see google cache link:
http://webcache.googleusercontent.com/search?q=cache:ONMgKfPE1EMJ:kevin.deldycke.com/2010/06/git-commit-history-reconstruction/+git+inject+commits&hl=en&strip=1



On Tue, Jan 4, 2011 at 5:11 PM, Thomas Ferris Nicolaisen
wrote:

> Maybe you could consider documenting each step as a commit instead? I know
> the author of Test-Driven JavaScript Development did this his example code:
>
> http://tddjs.com/code
>
> Basically, each tutorial is a git-repository with a number of commits. Each
> commit is a step in the tutorial, so you can walk through it and see what
> the code is like in each step.
>
> Here's a ruby script that enables you to walk up and down Git history:
> https://github.com/augustl/binbin/blob/master/git-walk
>
> And for coolness factor: here's how Christian integrated git-walk stepping
> in Emacs: http://cjohansen.no/en/emacs/live_coding_help_from_git_and_emacs
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To post to this group, send email to git-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> git-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/git-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.