Git Rebase

Elvenware Logo



I use rebasing when I have two branches, and sometimes want to update a particular branch with changes from the other branch. For instance, I use rebase in this scenario:

Here is what I do. I create two branchs:

Here is how it works:

Now I have the most recent copy of the student's repository in the master branch. If I want to update mycopy with the most recent changes from the student's repository, I:

There may well be conflicts at this point, but Git talks you through the process of fixing them. Just edit the files that need to be fixed up. See the section in this document on merging code if you need help on this. Then continue the rebase:

The end result is that I have two copies of the students code:

I think it is obvious from the above, but it is probably worth saying anyway. When I work on a student's code, I only use mycopy. So I spend 90 percent of my time in mycopy. I only switch back to master in order to pull the most recent version of the student's code. When I want to update my copy based on the most recent version of the student's code, I switch to the mycopy branch, and then rebase.

Copyright © 2017 by Charles Calvert