0
0
Gitdevops~30 mins

Merge commit creation in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Merge Commit Creation
📖 Scenario: You are working on a project with two branches: main and feature. You want to combine the changes from the feature branch into main using a merge commit. This is a common task when multiple people work on different parts of a project.
🎯 Goal: Learn how to create a merge commit by merging the feature branch into the main branch using Git commands.
📋 What You'll Learn
Create a new Git repository
Create an initial commit on the main branch
Create and switch to a branch called feature
Make a commit on the feature branch
Switch back to main branch
Merge the feature branch into main with a merge commit
Show the commit history to confirm the merge commit
💡 Why This Matters
🌍 Real World
Merging branches with a merge commit is common when combining work from different team members or features in software projects.
💼 Career
Understanding merge commits is essential for collaboration in software development and version control workflows.
Progress0 / 4 steps
1
Initialize repository, create initial commit, and create feature branch
Initialize a new Git repository with git init. Create a file initial.txt with content This is the initial file. using echo "This is the initial file." > initial.txt. Add it with git add initial.txt and commit it with git commit -m "Initial commit". Then create and switch to a branch called feature using git checkout -b feature.
Git
Need a hint?

Use git init to start a new repo. Use echo "This is the initial file." > initial.txt, then git add initial.txt and git commit -m "Initial commit". Finally, use git checkout -b feature to create and switch to the feature branch.

2
Create a commit on the feature branch
Create a new file called feature.txt with content This is a feature file. using echo "This is a feature file." > feature.txt. Add it to Git with git add feature.txt and commit it with the message "Add feature file" using git commit -m "Add feature file".
Git
Need a hint?

Use echo "This is a feature file." > feature.txt to create the file. Then add and commit it with the exact commit message.

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

Use git checkout main to switch branches.

4
Merge feature branch into main and show commit history
Merge the feature branch into main using git merge feature. Then show the commit history with git log --oneline --graph --all to confirm the merge commit.
Git
Need a hint?

Use git merge feature to merge. Then use git log --oneline --graph --all to see the merge commit in the history.