Rebase
Goal
- This project is about rebase. Rebasing is an alternative to merging.
Hints
- Try to solve the following tasks with the help of the Slides and the Cheatsheets.
- If you still run into problems, you'll find an expandable hint block for every task with a detailed description of the solution.
Task 1
- Leave the repository
conflictand create a new one:
cd .. # Leave the directory conflict
mkdir rebase # Create a new directory rebase
cd rebase # Change into that directory
git init # Create a new Git repository
Solution (Click on the arrow if you are stuck)
- Leave the directory
conflictwith the commandcd ... - Run the command
pwdand you should see/root/workspaceas a result. - If you got a different result, run
cd /root/workspaceto change into the right directory. - When you are in the right directory, run
mkdir rebase. - Change into the newly created directory with
cd rebase. - Run
git initwhich creates a new git repository in the current directory.
Task 2
- Create the following graph. Each commit/node should have the following properties:
- Node name = commit message
- Each commit (except merge commits) should create a file with the name of the commit message.
- Example: commit
C1creates a new fileC1.
Solution (Click on the arrow if you are stuck)
- Create the branch
us-42withgit switch -c us-42. - Create commit
C1by creating and commiting a fileC1. - Repeat the same for
C2. - Create the branch
testingwithgit switch -c testing. - Create commit
C3. - Switch back to
us-42withgit switch us-42. - Create commit
C4.
Task 3
Do a rebase, such that the changes of C3 are applied to C4. The branch us-42 should point on the new C3 commit.
Solution (Click on the arrow if you are stuck)
- You should now have a branch
us-42and a branchtesting. - The branch
testingdoes not include the latest changes ofus-42. - We want to change this by doing a rebase.
- For that, switch to the branch
testingwithgit switch testing. - Begin the rebase with
git rebase us-42. Now, the changes oftestinginclude all other changes ofus-42. - As a last step, we want to integrate the changes of
testingintous-42. - Switch to the branch
us-42withgit switch us-42. - Execute a fast forward merge with
git merge testing. - Review the result with
git log.