0
0
Gitdevops~20 mins

git rebase basic usage - Mini Project: Build & Apply

Choose your learning style9 modes available
Git Rebase Basic Usage
📖 Scenario: You are working on a project with a main branch called main and a feature branch called feature. The main branch has new commits that you want to include in your feature branch to keep it up to date.
🎯 Goal: You will learn how to use git rebase to move your feature branch commits on top of the latest main branch commits. This helps keep a clean project history.
📋 What You'll Learn
Create a new branch called feature from main
Add a commit to the feature branch
Rebase the feature branch onto the latest main branch
Show the commit history after rebasing
💡 Why This Matters
🌍 Real World
Developers often need to keep their feature branches up to date with the main branch to avoid conflicts and maintain a clean history.
💼 Career
Knowing how to use <code>git rebase</code> is essential for collaborative software development and version control workflows.
Progress0 / 4 steps
1
Create the feature branch and add a commit
Create a new branch called feature from main using git checkout -b feature main. Then create a file named feature.txt with the content Feature work and commit it with the message add feature work.
Git
Need a hint?

Use git checkout -b feature main to create and switch to the feature branch. Then create the file and commit it.

2
Add a new commit to main branch
Switch back to the main branch using git checkout main. Create a file named main.txt with the content Main branch update and commit it with the message update main branch.
Git
Need a hint?

Use git checkout main to switch back. Then create and commit the new file.

3
Rebase the feature branch onto main
Switch to the feature branch using git checkout feature. Then run git rebase main to move your feature commits on top of the latest main commits.
Git
Need a hint?

Use git checkout feature to switch back. Then run git rebase main to update your branch.

4
Show the commit history after rebasing
Run git log --oneline --graph --all to display the commit history graph showing the rebased commits.
Git
Need a hint?

Use git log --oneline --graph --all to see a simple graph of all commits.