🐙
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 Remote Repositories
  2. Collaborating with Git - Practice Scenarios

Collaborative Workflow with Forking and Pull Requests

Let's go through a practical step by step process, from forking the repository to creating a feature branch, making changes, and finally submitting a pull request for review and merging.

Scenario

Let's imagine that Alice, a developer, wants to contribute to an open-source project called "AwesomeApp." The project is hosted on a platform like GitHub, which supports the forking and pull request workflow.

Step 1: Forking the Repository

To contribute to "AwesomeApp," Alice needs to fork the repository. Forking creates a copy of the project under Alice's GitHub account, allowing her to freely make changes without affecting the original codebase.

  • Alice goes to the "AwesomeApp" repository on GitHub.

  • She clicks on the "Fork" button in the top-right corner of the repository page.

  • GitHub creates a copy of the repository under Alice's GitHub account.

Step 2: Cloning the Forked Repository

After forking the repository, Alice needs to clone it to her local machine to start working on the changes.

  • Alice opens a terminal on her machine.

  • She uses the following Git command to clone the forked repository

git clone https://github.com/Alice/AwesomeApp.git

Note: Replace "Alice" with her GitHub username.

  • The repository is now cloned to Alice's local machine.

Step 3: Creating a Feature Branch

To make changes to the project, Alice should create a new branch dedicated to her feature or bug fix.

  • Alice navigates into the cloned repository's directory:

cd AwesomeApp
  • She creates a new branch, naming it descriptively:

git checkout -b alice-add-new-feature

This command creates and switches to the new branch, alice-add-new-feature

Step 4: Making Changes

Now that Alice has created a feature branch, she can start making the desired changes to the codebase.

  • Alice opens the code files using her preferred text editor or IDE.

  • She makes the necessary modifications, adds new functionality, or fixes bugs.

Step 5: Committing Changes

Once Alice has made the desired changes, she needs to commit them to the feature branch.

  • Alice stages the changes she made:

git checkout -b alice-add-new-feature
  • This command stages all the modified and new files for commit.

  • She commits the changes with a descriptive message:

git commit -m "Add new feature: XYZ"

Replace "XYZ" with a brief description of the added feature.

Step 6: Pushing the Feature Branch

After committing the changes locally, Alice needs to push the feature branch to her forked repository on GitHub.

  • Alice pushes the feature branch:

git push origin alice-add-new-feature
  • This command pushes the branch to Alice's forked repository.

Step 7: Creating a Pull Request

Now that Alice has pushed her feature branch, she can open a pull request to propose the changes to the original "AwesomeApp" repository.

  • Alice navigates to her forked repository on GitHub.

  • She clicks on the "New Pull Request" button near the top of the repository page.

  • GitHub compares the changes in Alice's feature branch with the main branch of the original repository.

  • Alice reviews the changes, adds a descriptive title and comment, and clicks on the "Create Pull Request" button

Step 8: Review and Merge

After Alice has created the pull request, the project maintainers will review her changes and decide whether to merge them into the main codebase.

  • The maintainers of "AwesomeApp" receive a notification about the new pull request.

  • They review the proposed changes, provide feedback, and discuss any necessary modifications with Alice through comments.

  • Alice can continue making changes and pushing them to the feature branch based on the feedback until the pull request is approved.

  • Once the maintainers are satisfied with the changes, they merge Alice's pull request into the main branch of "AwesomeApp."

  • Alice's contribution is now a part of the project, and her feature is available to all users of "AwesomeApp."

PreviousPushing and Pulling ChangesNextResolving Conflicts in a Pull Request

Last updated 1 year ago

Was this helpful?

🤝