0
0
Gitdevops~30 mins

Why merging combines work in Git - See It in Action

Choose your learning style9 modes available
Why merging combines work
📖 Scenario: You are working on a team project using Git. Two team members have made changes in separate branches. You want to combine their work into the main branch so everyone has the latest updates.
🎯 Goal: Learn how to merge two branches in Git to combine work from different team members into one branch.
📋 What You'll Learn
Create a new branch called feature from main
Make a change in the feature branch
Switch back to main and make a different change
Merge the feature branch into main
Show the combined changes after merging
💡 Why This Matters
🌍 Real World
Teams use Git merging to combine work from different developers safely and keep the project up to date.
💼 Career
Understanding merging is essential for collaboration in software development and DevOps roles.
Progress0 / 4 steps
1
Create a new branch and add a file
Create a new branch called feature from main and create a file named file.txt with the content Feature work in the feature branch.
Git
Need a hint?

Use git checkout -b feature to create and switch to the new branch. Use echo to create the file and git commit to save changes.

2
Switch to main and add a different file
Switch back to the main branch and create a file named file.txt with the content Main work in the main branch.
Git
Need a hint?

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

3
Merge feature branch into main
While on the main branch, merge the feature branch into main using the git merge feature command.
Git
Need a hint?

Use git merge feature while on main to combine the changes.

4
Show the combined file content after merge
Use the cat file.txt command to display the content of file.txt after the merge.
Git
Need a hint?

Use cat file.txt to see the combined content after merging.