We recently switch from Bitbucket to Github. One feature we're missing is the ability to create PRs or Auto-merge commits made onto a "release" branch directly to our development branch. We had it set so if a bug was fixed in the "release" branch, which was branched off of development just prior to release, it would auto-create a PR and merge the PR if there were no conflicts.
How are teams using Github to accomplish this? I don't see it as a default configuration, but I'm assuming teams are doing something like this as it's pretty common.
I saw answers to a similar question on Can GitHub automatically merge branches? . I think it will solve your problem. It seems Github has introduced a new auto merge feature in 2020 december.
Related
Developers keep making the mistake on hotfixes to release branches in github. Here are the steps we have right now
git checkout --track origin/release_xxxx (make sure you are on the release branch)
git checkout -b yourName/yourTicketNumber (the hotfix branch)
Modify your code
Post a PR
modify the PR's base branch back to release_xxx
I am wondering if there is a slick way on the last step that once in a while gets missed to automatically use the branch it was branched from instead of main?
Perhaps I just need to create a postHotfix.sh and do the work in there but then people need github tools installed. Any other solutions?
I don't know of an automatic solution, but you can change the base branch when raising your PR in the GitHub UI:
If you're using the GitHub CLI, you can add a -B (or --base) branch as an argument: https://cli.github.com/manual/gh_pr_create
During the past few days I have struggled with how to handle versioning and our branching strategy while using Azure DevOps, so I decided to find some more information regarding how Microsoft does it..
However.. the versioning-part isnt really shared anywhere from what I have seen.. but I just watched how they handle branching over at this video:
Git patterns and anti-patterns for successful developers
However.. the part I dont quite get is.. its quite common to have your verison of your product configured as variables in your yaml. So for instance, during development you might have the following variables setup:
variables:
Major:1
Minor:1
Patch:0
Now lets say that we release version 1.1 and create our release-branch according to the above "relase flow" git stratgey.. we would once the release branch is created "bump" the version in our master-branch to for instance:
variables:
Major:1
Minor:2
Patch:0
Now.. all new code thats branched of master would end up with version 1.2.0.. however.. if we suddenly need to hotfix our production code, the release flow branching stratgey mentioned in the video would branch of master for our bugfix, this would give us a branch which has version 1.2.(1), but the minor and major we actually are trying to "patch" is 1.1... so as suggested by the video, if we now PR our bugfix into master and our release-branch, we would also not just patch our prodiction code with the bugfix, we would bring it up to a new minor-version.. which I would argue is not a prefered way of versioning the code, since the "logical" verison for our new bugfixed production-code would be 1.1.1
Any ideas of how this is solved?
The way I understand it in the release flow org site, if you cut a release branch to correspond with what is in production, your maintenance work (i.e. hotfixes/patches) happen on the release/1.1.0 branch. You then apply the same fix to mainline (e.g. master). See the following diagram:
Furthermore, if you want to avoid full branch merges to propagate fixes to mainline and other release branches, git cherry-pick is your friend. Just cherry-pick the commits into another hotfix off of mainline or another release branch and make any adjustments needed to get it working with that version of the code.
Cheers!
Azure DevOps and Release flow, hot to handle versioning when hotfixing?
If the minor and major we actually are trying to "patch" is 1.1 and you do not want to patch production code with the bugfix branch, we could try to merge the master branch to the hotfix after completing the development work, give the version 1.2.1.
After completing the above PR, we could merge the hotfix branch to the master, then we went back to our previous scene:
Now, we could forget the hotfix branch and continue to develop and release on the master branch.
We started using GitHub as Source control in our project recently and we are using Feature branches to work on the features. Once we are done with our development, we merge it to the develop branch using pull request.
During the merge if there are conflicts, we resolve using the web editor. But during this process all the commits done on the file with conflicts get included as a part of the feature branch.
Does anyone know how can i avoid this and make sure the feature branch stays clean?
You should only merge the feature branch into the develop branch (not the other way around). Then resolve the conflicts right there in the develop branch itself.
git checkout develop
git merge feature-branch
resolve conflicts in develop
git push
Note: If you are not too comfortable with the conflict resolution process, then best to create a 'develop-merge' branch, then merge the feature branch into it before creating a cleaner pull request for merging the new 'develop-merge' into 'develop' branch.
This way the develop branch will include all the features at the same time the feature branch won't be convoluted.
Our current stash repository has a Master and Develop branch.
Anytime if a developer is working on a story a developer creates a branch and once the coding is done a pull request is raised to merge to develop.
So far it has been good but when two developers are working on different feature branches on a same Repository if a developer merges his changes to develop and other one is still working on, there are issues like merge conflicts and we don't want the two different feature branches to be released together.
I know this is not an issue but we want to avoid release multiple feature branches at a time.
Any thoughts on this on what are the best practices.
I would suggest to create tags after you have merge to "develop" branch. There is no harm if you wish to release code from "master" branch using tags as well.
Honestly speaking there aren't any hard lines drawn on how you wish to release your code from Git hosted repos?
You may like to follow this sequence
rebase the feature brnach of second dev from develop branch to get changes of dev1 and avoid merge conflicts
git checkout feature_branch2
git rebase develop
merge feature-branch2 to develop branch
git checkout develop
git merge feature_branch2
tag the version you wish to release
git checkout provide_version_you_wish_to_release
git tag tag_name
The best practice is that the 2nd developer should first rebase his feature branch from "develop" branch and then merge his changes back to "develop" branch by creating a pull request.
If you don't wish to release changes from two feature branches simultaneously, you can create tags on the "develop" branch after a merge is successful and release code using these tags.
Hope this helps!
We have a dev branch in the team. I want to remove HEAD~9 commit from the dev branch as it was an accidental merge from a feature branch. I don't want to rewrite history as it might lead to problems with working copies of other developers. What other alternatives do I have?
One alternative that I thought is to branch off from dev, remove the commit from that branch, and then merge the new branch to dev. Can this lead to any problem later?