AZ-400: Designing and Implementing Microsoft DevOps Solutions
Branching Strategies for Source Code
Implement fork workflow
In this guide, you’ll learn how to safely experiment with a project by creating a personal copy of an Azure DevOps repository. Forking enables you to develop features, test changes, and submit pull requests back to the original codebase—all without affecting the upstream repository. This workflow is perfect for open source contributions and large-team collaboration.
1. Forking a Repository
- Sign in to Azure DevOps as your user (e.g., Lloyd).
- Navigate to Repos and locate the KodeKloud GIFs repository.
- Click Fork, name your fork (for example,
KodeKloudGifts.LloydChristmas
), choose the branches to include, and confirm.
Note
Forks are isolated copies—your changes won’t affect the original repository until you open a pull request.
After the fork completes, the Clone button points to your new repository:
2. Cloning and Setting Up Your Fork
Use Git to clone your fork, not the original:
git clone https://dev.azure.com/KodeKloudDemo/KodeKloudGifts/_git/KodeKloudGifts.lloyd.christmas
Sample output:
Cloning into 'KodeKloudGifts.lloyd.christmas'...
remote: Azure Repos
remote: This repository is a fork. Learn more at https://aka.ms/whatisafork.
remote: To add its upstream as a remote, run:
remote: git remote add upstream https://dev.azure.com/KodeKloudDemo/KodeKloudGifts/_git/KodeKloudGifts
Unpacking objects: 100% (37/37), done.
Note
After cloning, run the following to set up the original repo as upstream
:
git remote add upstream https://dev.azure.com/KodeKloudDemo/KodeKloudGifts/_git/KodeKloudGifts
Open your project in Visual Studio Code:
3. Modifying the Code
Edit Pages/Home.razor to showcase Lloyd’s GIF shop:
@page "/"
<PageTitle>Home</PageTitle>
<h1>Welcome to Lloyd’s KodeKloud Gift Shop!</h1>
<p>
Discover Lloyd’s handpicked collection of quirky and unique GIF gifts.
Whether for a friend, family, or yourself, shop the fun here!
</p>
Commit and push your updates:
git status
git add Pages/Home.razor
git commit -m "Update Home.razor with new shop details"
git push origin master
4. Comparing Fork vs. Upstream
Switch between your fork and the upstream repository in Azure DevOps to verify changes:
Your fork’s Home.razor now reflects the new content, while the upstream remains unchanged.
5. Creating a Pull Request
When you’re ready to merge, create a pull request:
- In your fork, go to Pull Requests > New Pull Request.
- Select master (or your feature branch) as both source and target, if applicable.
- Add a descriptive title and summary.
Tag reviewers, link work items, and adjust settings:
Once submitted, maintainers can review and merge your contribution.
Workflow Summary
Step | Command / Action | Purpose |
---|---|---|
Fork | Click Fork in Azure DevOps | Create isolated repository copy |
Clone | git clone <fork-url> | Download your fork locally |
Add Upstream Remote | git remote add upstream <original-url> | Keep fork in sync with the original repo |
Develop & Commit | git add → git commit -m → git push origin <branch> | Make and push changes to your fork |
Create Pull Request | Pull Requests > New Pull Request | Propose changes to the upstream repository |
Links and References
Watch Video
Watch video content