🐙
Git Developer Guide
About
  • Overview
  • Scope of this book
  • Table of Content
  • 🐢Introduction to Version Control
    • What is Version Control?
    • Overview of git and it's benefits
    • Setting up Git on Different Platforms
  • 🍼Git Fundamentals
    • Initialising a new Git repository
    • Understanding the Git Workflow
    • Committing Changes and Writing Good Commit Messages
    • Viewing and Navigating Commit History
    • Git Basics - Practice Scenarios
      • Initialising a Git Repository
      • Committing Changes
      • Exploring Commit History
      • Amending and Undoing Commits
  • 🦕Working With Git
    • What is Git Branch?
    • Creating and Switching Between Branches
    • Merging Branches and Resolving Conflicts
    • Best Practices for Branch Management
    • Git Workflows
    • Git Log
    • Git Stash
    • Working with Git - Practice Scenarios
      • Creating and Switching Between Branches
      • Merging Branches and Resolving Conflicts
      • Branching Strategies in a Team Project
      • Rolling Back to a Previous Version
      • Experimenting with Feature Branches
      • Working with Stash
  • 🤝Working with Remote Repositories
    • Cloning a Repository from Remote
    • Pushing and Pulling Changes to and from Remote Repositories
    • Collaborative Workflows - Forking, Branching, and Pull Requests
    • Resolving Conflicts in a Collaborative Environment
    • Collaborating with Git - Practice Scenarios
      • Cloning a Remote Repository
      • Pushing and Pulling Changes
      • Collaborative Workflow with Forking and Pull Requests
      • Resolving Conflicts in a Pull Request
  • 🏆Advanced Git Features
    • Aliases and Custom Configurations
    • Working with Tags and Releases
    • Rewriting Commit History with Interactive Rebase
    • Utilising Git Hooks for Automation
    • Advanced Git Features - Practice Scenarios
      • Creating Custom Git Aliases
      • Working with Tags and Releases
      • Rewriting Commit History with Interactive Rebase
      • Using Git Hooks for Automated Testing
  • 😎Git in Real-World
    • Managing a Project with Multiple Contributors
    • Integrating Git with Continuous Integration, Continuous Deployment (CI, CD)
    • Versioning Assets with Git LFS (Large File Storage)
    • Deploying a Web Application using Git
    • Git In Real World - Practice Scenarios
      • Managing a Project with Multiple Contributors
      • Integrating Git with CICD Pipelines
      • Versioning Assets with Git LFS
      • Deploying a Web Application using Git
  • Git Troubleshooting
    • Common Mistakes and Pitfalls When Using Git
    • Undoing Changes with Git - Reverting and Resetting
    • Recovering Lost Commits or Branches
    • Dealing with Repository Corruption or Other Issues
  • Git Best Practices and Tips
    • Creating efficient git workflows: writing clean code for faster reviews
    • The importance of clean code in collaborative development
    • Significance of consistent naming conventions & coding Standards
    • Good code documentation for better git workflows
    • Writing meaningful git commit messages
    • Atomic commits in git & it's benefits for software teams
    • Structuring code & managing dependencies for better git workflows
    • Git branching strategies for software teams
  • Conclusion & Next Steps
    • Recap of Key Concepts and Commands
    • Further Resources for Expanding Git Knowledge
    • Encouragement and Tips for Continued Learning and Practice
  • License Considerations
Powered by GitBook
On this page

Was this helpful?

  1. Working With Git
  2. Working with Git - Practice Scenarios

Experimenting with Feature Branches

Scenario

You are part of a team developing a web application. The team decides to introduce a new feature that allows users to upload profile pictures. This new feature requires changes in multiple areas of the codebase, such as the frontend, backend, and database.

Creating a Feature Branch

To start working on the new profile picture feature, you would create a new branch dedicated to this task. Let's name it "profile-picture-feature". Here's how you can create the branch using the Git command line:

git checkout -b profile-picture-feature

The command git checkout -b creates a new branch based on the current branch and switches to it.

Making Changes in the Feature Branch

Once you have switched to the feature branch, you can start making the necessary modifications for the profile picture feature. For example, you might need to create a new route in the backend, update the user interface in the frontend, and modify the database schema. Make the required changes in their respective files and directories.

Committing Changes

Git allows you to save your changes as commits, which act as checkpoints in your development process. Committing frequently with descriptive messages is essential for maintaining a clear history. To commit the changes you made in the feature branch, use the following commands:

git add .
git commit -m "Implemented profile picture upload feature"

The first command, git add ., stages all the modified files for the commit. The second command, git commit -m, creates a commit with a concise message explaining the changes made.

Iterating and Collaborating

As the development progresses, you might need to iterate on the feature, fix bugs, or add enhancements. You can continue making changes in the feature branch, committing them, and testing them thoroughly.

Branches are the best way to create a safe environment for experimentation and collaborative work.

Merging the Feature Branch

Once the profile picture feature is complete and tested, it's time to merge the changes back to the main branch. The following steps illustrate the process of merging the feature branch into the main branch:

  • Switch to the main branch

git checkout main
  • Merge the feature branch into the main branch

git merge profile-picture-feature

Resolve conflicts (if any)

During the merge, Git may encounter conflicts if changes made in the feature branch conflict with the ones made in the main branch. You'll need to resolve these conflicts manually.

Review the changes

After resolving conflicts, review the merged changes to ensure everything is working as expected.

Commit the merge

Once you are satisfied with the changes, commit the merge

git commit -m "Merged profile picture feature"

Feature branches play a vital role in isolating development efforts, enabling experimentation, and maintaining code stability. By creating, making changes, and merging feature branches, you can collaborate effectively and ensure a smooth development process.

PreviousRolling Back to a Previous VersionNextWorking with Stash

Last updated 1 year ago

Was this helpful?

🦕