Git Flow to Azure DevOps

July 08, 2022

 


  1. Connect Git to Azure DevOps – HTTS/SSH/PAT

        2. Initialize local Git project folder (git init

      1.   Git add * (to add all files to the Git Repo)
      2.   Git commit -m ‘comment’

        3. Create PAT token in Azure DevOps 

      1.     Ensure you’re in the correct organization
      2.     User Settings → Personal Access Token

      • Click on New Token to create a new PAT (You can restrict the scope of access that's associated with the token, eg. Role base access.) Below image is an example of restricting access for a token.

List of scopes:

Work Items-Work items, queries, backlogs, plans, and metadata

Code-Source code, repositories, pull requests, and notifications

Build-Artifacts, definitions, requests, queue a build, and updated build properties

Release-Read, update, and delete releases, release pipelines, and stages

Test Management-Read, create, and updated test plans, cases, and results

Packaging-Create, read, update, and delete feeds and packages


      • Copy the token, this is not stored in Azure


       4. Set origin point (git remote add origin xxx)

      • Git remote add origin https://Token@dev.azure.com/organization/project/_git/git repo


       5. Push to Azure DevOps (git push origin master) - this will push from local git branch to Azure DevOps master branch.

Check Azure repo master branch for the files that have been pushed to confirm



       6. Create new Feature and Release branches (git checkout -b feature / release)

Create and push content to feature branch :

git checkout -b feature 

git push origin feature   

      • check Azure Repo (below screenshots) for new feature branch and files in this branch


Create release branch the same as feature branch and push to Azure DevOps


Push to release branch (git push origin release), check Azure Repo (below screenshots) for new release branch and files in this branch.


       7. Helm Charts Flow:

      • AD will commit the changes to the feature branch
      • AO will review then merge them into the Release branch, then deployment (UAT/PROD) will be done from the Release branch.
      • Once the deployment is stable and successful in PROD then AO will merge the release into the master branch.


Example:

Create a new file (feature.txt) on local git repo and push to the feature branch

git add feature.txt

git commit -m “new file for feature branch” 

git push origin feature



       8. Create a pull request to merge the code from the feature into the release branch

Merge feature branch into release branch

Ensure to check you are pulling from and to the correct branches (highlighted in screenshot below)

Check the files/codes comparison to identify and select what you want to merge, then click ‘Complete’ to initiate the merge.

feature branch should be deleted after promotion but this is based on the project and Teams to decide on this deletion criteria per feature (eg. per sprint )

Check release branch for changes


The UAT/PROD deployments (pipelines) will be done from this release branch before merging the stable codes into the master branch.



       9. Create a pull request to merge the code from the release branch into the master branch, as was done for feature to release in step 8.

Merge release branch into master branch

Ensure to check you are pulling from release to master branch (highlighted in screenshot below)

Check the files/codes comparison to identify and select what you want to merge, then click ‘Complete’ to initiate the merge.

NB: We should not delete the release branch as we would do for the feature branch after merging 

Leave ‘Delete release after merging’ checkbox  UNCHECK 

 Check the master branch to ensure the changes has been merged

No comments:

Powered by Blogger.