Create a new branch called feature1, make some changes to it, and merge it back into the main branch. Ensure there are no merge conflicts.
Here’s how to create a new branch called feature1
, make changes in it, and then merge it back into the main
branch without any merge conflicts:
Step 1: Create a New Branch
Make sure you're in your project directory (the one you initialized as a Git repository).
Create a new branch called
feature1
:git checkout -b feature1
Step 2: Make Some Changes
Open a file (e.g.,
README.md
) in your text editor and make some changes. For example, you can add a new line:## Feature 1 Implementation This section describes the implementation of feature 1.
Save the changes.
Add the modified file to the staging area:
git add README.md
Commit the changes in the
feature1
branch with a meaningful message:git commit -m "Add feature 1 description to README"
Step 3: Switch Back to the Main Branch
Switch back to the
main
branch:git checkout main
Step 4: Merge the Feature Branch
Merge the
feature1
branch into themain
branch:git merge feature1
Step 5: Verify the Merge
- Open the
README.md
file again to ensure the changes fromfeature1
have been merged intomain
.
Step 6: Clean Up (Optional)
If you no longer need the
feature1
branch, you can delete it:git branch -d feature1
Summary
You’ve successfully created a new branch, made changes in it, and merged those changes back into the main
branch without any merge conflicts. If you have any questions or run into issues, feel free to ask!