0
0
Gitdevops~30 mins

Trunk-based development in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
Trunk-based Development with Git
📖 Scenario: You are working on a small team project where everyone commits their changes directly to the main branch, called main. This method is called trunk-based development. It helps keep the project simple and avoids long-lived branches.In this project, you will practice creating a new file, committing it to main, and then updating it with a new commit.
🎯 Goal: Learn how to use trunk-based development by making commits directly on the main branch using Git commands.
📋 What You'll Learn
Create a new file called feature.txt with specific content
Add the file to Git staging area
Commit the file with a clear message on the main branch
Modify the file and commit the changes again on the main branch
Show the commit log to verify the commits
💡 Why This Matters
🌍 Real World
Trunk-based development is used in many software teams to keep the codebase simple and avoid complex merges. It helps teams deliver features quickly and safely.
💼 Career
Understanding trunk-based development and Git commands is essential for software developers, DevOps engineers, and anyone working in collaborative coding environments.
Progress0 / 4 steps
1
Create a new file and initialize Git
Create a new file called feature.txt with the text Initial feature content. Then initialize a new Git repository with git init.
Git
Need a hint?

Use echo to write text into the file. Use git init to create a new Git repository.

2
Add the file to staging area
Add the file feature.txt to the Git staging area using git add feature.txt.
Git
Need a hint?

Use git add followed by the file name to stage the file.

3
Commit the file on main branch
Commit the staged file with the message Initial commit of feature.txt using git commit -m "Initial commit of feature.txt". Ensure you are on the main branch.
Git
Need a hint?

Use git commit -m with your message in quotes to commit.

4
Modify the file and commit the update
Append the text More feature details to feature.txt. Then add and commit the changes with the message Update feature.txt with more details. Finally, show the commit log with git log --oneline.
Git
Need a hint?

Use >> to append text to a file. Then stage and commit the changes. Use git log --oneline to see short commit messages.