0
0
Gitdevops~30 mins

Fast-forward merge in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Fast-forward merge
📖 Scenario: You are working on a project using Git. You have a main branch called main and a feature branch called feature. You want to practice merging the feature branch into main using a fast-forward merge.
🎯 Goal: Learn how to create branches, make commits, and perform a fast-forward merge in Git.
📋 What You'll Learn
Create a branch called feature from main
Make a commit on the feature branch
Switch back to main branch
Perform a fast-forward merge of feature into main
Show the commit log to confirm the merge
💡 Why This Matters
🌍 Real World
Fast-forward merges are common when a feature branch is directly ahead of the main branch without any divergent commits. This keeps the commit history clean and linear.
💼 Career
Understanding fast-forward merges is essential for software developers and DevOps engineers to manage code changes efficiently and maintain a clear project history.
Progress0 / 4 steps
1
Create the feature branch from main
Run the command git branch feature to create a new branch called feature from the current main branch.
Git
Need a hint?

Use git branch feature to create the branch.

2
Switch to the feature branch and make a commit
Run git checkout feature to switch to the feature branch. Then create a file called feature.txt with the content Feature work. Stage the file with git add feature.txt and commit with the message add feature work.
Git
Need a hint?

Switch branches with git checkout feature. Use echo to create the file, then add and commit it.

3
Switch back to the main branch
Run git checkout main to switch back to the main branch.
Git
Need a hint?

Use git checkout main to switch branches.

4
Perform a fast-forward merge and show the commit log
Run git merge feature to merge the feature branch into main using a fast-forward merge. Then run git log --oneline --graph --all to display the commit history and confirm the merge.
Git
Need a hint?

Use git merge feature to merge and git log --oneline --graph --all to see the commits.