Skip to content

Commit

Permalink
Add feature branch update instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetchel committed Dec 10, 2021
1 parent f236243 commit 34d535e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,40 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## For maintainers: Updating feature branches

This repository uses feature branches to associate code with specific modules on Microsoft Learn. Any changes you make to the default branch will likely need to be propagated to each feature branch in this repo. A common example is when we need to update Node packages in `package.json`.

Here's one way to update the remote feature branches when you make a change to the default branch. Note that this process deletes all local branches except for `main`.

```bash
# Synchronize with the remote main branch
git checkout main
git pull origin main
# Delete all local branches except for main
git branch | grep -ve "main" | xargs git branch -D
# List all remote branches except for main
branches=$(git branch -r 2> /dev/null | grep -ve "main" | cut -d "/" -f 2)
# Synchronize each branch with main and push the result
while IFS= read -r branch; do
# Fetch and switch to feature branch
git fetch origin $branch
git checkout $branch
# Ensure local environment is free of extra files
git clean -xdf
# Merge down main
git merge --no-ff main
# Break out if merge failed
if [ $? -ne 0 ]; then
break
fi
# Push update
git push origin $branch
done <<< "$branches"
# Switch back to main
git checkout main
```

# Legal Notices

Microsoft and any contributors grant you a license to the Microsoft documentation and other content
Expand Down

0 comments on commit 34d535e

Please sign in to comment.