commit
in case you screw up.push
project code to a server to make it live (with a little help from GitHub).main
branch;main
main
Branch;$ git checkout -b [feature-name]
main
and conflicts are resolved.$ git checkout main
$ git merge [feature-name]
See About Pull Requests on GitHub
Stashing your work is like clipboard on steroids: it takes all the changes in your working copy and saves them for you on a new clipboard.
You can always restore the changes from that clipboard in your working copy
No limit to how many stashes you can have. Also, a Stash is not bound to the branch where you created it: when you restore it, the changes will be applied to your current HEAD branch, whichever this may be.
before checking out a different branch.
before pulling remote changes.
before merging or rebasing a branch.
Feature Development
Scenario: A team of developers, including Sarah (front-end developer), John (back-end developer), and Emily (QA tester), is working on a web application. They need to implement a new feature that involves significant changes to the codebase.
Use of Branching: Sarah creates a feature branch named "user-authentication" from the main development branch. John creates another feature branch named "database-integration" for the backend changes. Emily sets up a testing environment linked to the feature branches. Each developer works on their respective branches, making changes, committing them, and pushing them to the remote repository. Once the features are completed and tested, they are merged back into the main branch through pull requests.
Bug Fixing
Scenario: A critical bug is discovered in the production environment, impacting the user experience. The team, including Mark (software engineer) and Lisa (QA tester), needs to address the bug urgently without disrupting ongoing development work.
Use of Branching: Mark creates a hotfix branch named "bug-fix" from the production branch to address the critical bug. He makes the necessary changes and commits them to the hotfix branch. Lisa conducts testing on the hotfix branch to ensure that the bug is resolved. Once the hotfix is verified, it is merged into both the production branch and any active development branches to ensure that the fix is applied universally.
Release Management
Scenario: A software company is preparing for a new release of their product. The team, including Alex (project manager) and Kate (technical writer), needs to stabilize the codebase, conduct final testing, and prepare release notes.
Use of Branching: Alex creates a release branch named "release-2.0" from the main development branch to isolate the code changes for the upcoming release. Developers focus on stabilizing the release branch by fixing bugs, addressing last-minute issues, and updating documentation. Kate works on preparing release notes and documentation based on the changes in the release branch. Once the release is ready, it is merged into the production branch to deploy the new version.
Experimentation and Prototyping
Scenario: A team, including Mike (software architect) and Rachel (UX designer), wants to experiment with new features or explore alternative solutions without impacting the stability of the main codebase.
Use of Branching: Mike and Rachel create experimental branches to prototype new features, test different implementations, or explore innovative ideas. These branches allow them to work independently on experimental features without affecting the main development workflow. Depending on the outcome of the experiments, changes may be integrated into the main codebase or discarded.
Code Review and Collaboration
Scenario: Multiple developers, including David (team lead) and Jessica (junior developer), are working on different parts of a project concurrently. They need a structured way to review each other's code, provide feedback, and collaborate effectively.
Use of Branching: Each developer creates a feature branch for the task they are working on. Once the feature is ready, they open a pull request, allowing team members to review the changes, provide feedback, and suggest improvements. David oversees the code review process, ensuring that changes are thoroughly reviewed before being merged into the main codebase.