🐙
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

Creating and Switching Between Branches

In software development, using branches is a common practice to isolate different features or bug fixes from the main codebase

Scenario

Let's imagine a scenario where you are working on a web application and have been assigned a task to develop a new feature. The application currently has a stable version deployed, and you want to work on the feature without impacting the live environment.

Let's demonstrating how to create a feature branch and switch to it:

  • Open your terminal or command prompt and navigate to the project directory where you have initialised Git.

  • Before creating a new branch, it's always a good practice to update your local repository with the latest changes from the remote repository. Use the following command to fetch the latest changes:

git fetch
  • Once you have the latest changes, it's time to create a new branch. In this case, we'll create a branch called "feature-branch" to work on our new feature. Execute the following command to create the branch:

git branch feature-branch

This command creates a new branch named "feature-branch" based on the current branch you are on (usually the main branch).

  • To switch to the newly created branch, use the following command:

git checkout feature-branch

Now you are on the "feature-branch" and ready to start working on your new feature.

Highlighting the benefits of isolating development in branches

Working on a feature branch provides several benefits, including:

  • Isolation: By creating a branch, you can develop and test your feature independently without impacting the stability of the main branch or the live environment.

  • Collaboration: Branches allow multiple developers to work on different features simultaneously, enabling parallel development and reducing conflicts between code changes.

  • Versioning: Each branch represents a different version of your codebase. This allows you to easily switch between branches to compare or revert changes.

  • Code review: With branches, you can submit your feature for code review separately from the main branch. This promotes collaboration and helps ensure the quality of the codebase.

  • Easy rollback: If an issue arises during development, you can easily switch back to the main branch or another stable branch, ensuring that your codebase is always in a deployable state.

It's essential to regularly merge the changes from the main branch into your feature branch to keep it up to date with the latest codebase as it reduces the chances of conflicts and makes the eventual merge back into the main branch smoother.

PreviousWorking with Git - Practice ScenariosNextMerging Branches and Resolving Conflicts

Last updated 1 year ago

Was this helpful?

🦕