0
0
Gitdevops~30 mins

git merge command - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the git merge Command
📖 Scenario: You are working on a project with two branches: main and feature. You want to combine the changes from the feature branch into the main branch to update the main project with new features.
🎯 Goal: Learn how to use the git merge command to combine changes from one branch into another safely and correctly.
📋 What You'll Learn
Create a new branch called feature from main
Make a commit on the feature branch
Switch back to the main branch
Merge the feature branch into main using git merge
💡 Why This Matters
🌍 Real World
Merging branches is a daily task in software development to combine new features or fixes into the main project code.
💼 Career
Understanding how to merge branches correctly is essential for collaboration in teams and managing code changes safely.
Progress0 / 4 steps
1
Create the feature branch and make a commit
Create a new branch called feature from main using git branch feature. Then switch to the feature branch using git checkout feature. Finally, create a new file called feature.txt with the content New feature added and commit it with the message Added feature.txt.
Git
Need a hint?

Use git branch to create the branch, git checkout to switch, then create and commit the file.

2
Switch back to the main branch
Switch back to the main branch using git checkout main.
Git
Need a hint?

Use git checkout main to switch back to the main branch.

3
Merge the feature branch into main
Use the git merge feature command to merge the changes from the feature branch into the main branch.
Git
Need a hint?

Run git merge feature while on the main branch to combine changes.

4
Verify the merge result
Run git log --oneline and cat feature.txt to verify that the feature.txt file from the feature branch is now in the main branch.
Git
Need a hint?

Use git log --oneline to see commits and cat feature.txt to see the file content.