This is the 7th part in the series of blog posts on managing the Azure DevOps using Terraform. You can find the series index here. Although this is the one of the part in the series, this can also be a completely independent post in itself. In this post, we’ll be using a Git repository to store the Terraform code files and discuss the best practices around it. This aligns with one of the practices in the Infrastructure as Code (IaC) framework and somewhat aligns with what is now a days known as GitOps framework. We’ll not go into details of if GitOps is suitable for Terraform or not into this post.
Read More »Tag: GitHub
Scale your Git workflow with Git hooks – 2
In our previous post, we discussed what are git hooks, how to install git hooks ,few of the local git hooks and custom hooks. This post is continuation of the same and we are going to discuss more types of git hooks and their customization.
Post-Checkout git hook
The post-checkout hook works a lot like the post-commit
hook, but it is called whenever you successfully check out a reference with git checkout.
Read More »
Scale your Git workflow with Git Hooks
Git hooks are a very useful feature in the git. Git hooks are scripts that you can place in a hooks directory. They are triggered every time an specific event occurs in a Git repository. They let you customize Git’s internal behavior and trigger customizable actions at key points in your CI/CD and git workflow.
Some of the common use cases include to encourage a commit policy, altering the project environment depending on the state of the repository, to trigger continuous integration workflows before and after commits, etc. However since scripts can be written as per the requirements at hand, you can use Git hooks to automate or optimize virtually any aspect of your development workflow.
Read More »
Working with remotes in Git, GitHub and Visual Studio
In previous post, we discussed about how to work with remotes in Git at command line. In this post, we are going to discuss how we can do the same from the very comforts of Visual Studio while we continue to host our source code on the GitHub. While it’s true that there is no command or built-in option available in Visual Studio to connect to GitHub, we can leverage one of the extensions available for GitHub.
Install GitHub Extension for Visual Studio
To search for this extension, let’s open Visual Studio first. From the tool bar menu, select Tools and then click on the ‘Extensions and Updates’:
Read More »
Save your changes temporarily in Git using Git Stash
This happens almost every now and then. You are in middle of working on some code changes, modified few files here and there and may be added new files. Now something else comes up urgently and you are asked to do it now. But you do not want to make a commit in middle of the work. In such a case, if you switch branch, your changes are carried over to the another branch as well. So you need a way to save your work temporarily. Fortunately, Git allows this functionality using what is known as Git Stash.
Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time.
Read More »
Using Path filters in Build definition in Azure DevOps / VSTS
Sometimes it happens that for the organization and maintenance purpose, you would like to keep all code related to one component of a product in one place only. Now that component may be complex component having multiple sub parts like API, UI, Database etc. Again, for the purpose of easy maintenance, you would like it all under one repository, which is not an bad idea. Now, imagine if you have different builds configured for different sub-components which are using this source code as their base and are configured to trigger on some event, say commit. Then for each small and big commit, it will trigger build in each of the configured builds. Ideally, if the change was related to only one sub-component say API, then you would need to trigger only API specific build and not the ones for the UI and/or Database. Read More »
Delete Branches in Git using commands
In git workflow, the ideal strategy to work is to fork a new branch, make changes and finally merge in the main development branches. Over the time, this results in creation of large number of branches which are not required and becomes stale. Although a branch is just a pointer to an commit and does not require more than 40 bytes of disk space, it can be painful to search a long list of branches and deciding what you want to work on. Also since we humans are not good with creating unique names for branches, they can also result in confusion.
Below are some steps to clean branches from git repository to remove the clutter.Read More »
Swap master branch with another branch in Git
In git, branch is just a pointer to the one of the commits. So you can create and remove branches very easily. Most of the time, you can select commit of your choice and create a new branch from their and delete the one you do not need. However, sometime you create one branch out of master, intending to merge it to master but later everyone starts using the same and it becomes kind of master. We ran into this situation with one of the source code repository. So to get back on track, we needed to swap the contents of the both branches. Read More »