Azure master branch doesnt show the merged commits - azure-devops

We are using Azure DevOps, recently came across the issue when some of the commits that was stated to be completed and merged to the master branch dont show up in Repos history.

Azure master branch doesnt show the merged commits
It depends on the merge method you choose when you PR.
Azure Repos has several merge strategies, and by default, all of them are allowed. You can maintain a consistent branch history by enforcing a merge strategy for PR completion.
So, if you select the Squash merge, which is a merge option that allows you to condense the Git history of topic branches when you complete a pull request. Instead of each commit on the topic branch being added to the history of the default branch, a squash merge adds all the file changes to a single new commit on the default branch.
In this case, the commits that was stated to be completed and merged to the master branch dont show up in Repos history.
You could check the document Merge strategies and squash merge for some more details.

Related

How to regroup some old commits on master?

On my GitLab repo every merge request is integrated as a single commit. However one day it failed partially due to a GitLab UI bug (if you merge in the UI with the squash option checked it will not squash if the squash option was not checked at the opening of the merge request).
Is there a way I could squash these commits in retrospect?

Branch deploys with old commit

I have two branches in Github. Master and CoolFeature.
When i check CoolFeature in Github i see that it is even with Master.
When i deploy through Team City the Master branch somehow i get a commit from the Master branch that is five commits behind. I can see it in Team City by checking the SHA1. Is there some feature i have missed?
When i deploy the CoolFeature branch then the latest changes works cause CoolFeature deploys the latest commit.
Edit:
When i checkout the master branch i get this message:
> git checkout origin/master
Note: checking out 'origin/master'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at e86824af5...
The SHA1 hash refered e86824af5... IS the latest commit. And this is the one i want to be deployed. But TeamCity deploys a commit that is five commits behind this one. I can see it in the log comparing the SH1 hash ids.

VSTS: Difference between default and compare branch

In my git repository I have three branches: master: default, dev: compare, and temp.
When I create a Pull Request from temp branch it defaults to dev as the target.
It is in contradiction with what Microsoft documentation says:
Change the default branch used to merge code into when your team
creates new pull requests. This is useful when you want to use a
branch other than master for the main line of development in your
repo.
Am I missing something?
For default branch, it helps you to treat the branch as default when cloning the git repo locally or creating a PR.
Such as if you treat master branch as default branch (by default), when you cloned the git repo locally, the local branch is master. And when you creating a PR, it will automatically treat master branch as the target branch.
For compare branch, it helps you to decide how many commits on the other branches are behind or ahead by comparing commits on other branches with the compare branch.
Such as for above example, develop branch is compare branch, and master branch and nn1 branch are compare with develop branch.
For comparing master branch with develop branch, there has 0 commits behind and 0 commit ahead (master branch same as develop branch). For comparing nn1 branch with develop branch, there are 3 commits behind and 48 commits ahead.
I did some quick tests in my VSTS tenant. It looks like the default branch of a new pull request is always the Compare branch, rather than the Default branch. So if you set your master branch as Compare branch, it should become to the default for new pull requests.
Not sure if it is bug of VSTS, or if they change the behavior of pull request without updating the doc.
Update:
I did some further research. It turned out that this change was introduced in a Oct 2016 feature roll out:
You can now set your compare branch to something other than the
default branch. This setting will be remembered on a per-user basis.
Pull requests and new branches created from the Branches page will be
based off the branch you set as the compare branch.
So the doc needs to be updated.

Branch Policy in Github

I have 2 branches in my github repository. How do I enforce a branch policy for Master branch such that any changes to it must require a code review from specific folks done ?
This is best managed by repos, not branches.
You can have one repo with the master branch, and one or several forks, from which developers can make pull request in order to request a merge to master of the original repo.
Only the "specific folks" are declared collaborators on the original repo, and can review the PRs and merge them.
Then the developers can synchronize their own fork.

Git conflicts in pull requests

I have 2 branches - master and develop
I have been doing some pull requests in my develop branch where it contains 5 items, in which it is the same as the number of items in master.
However, someone did some commits and pushed in a few more items into the master branch, and hence now it has 8 items.
As my pull request in the develop is still not yet approved/merged, whenever I tried to update my pull request, I am getting the message stating that This pull request can't be merged. You will need to resolve conflicts to be able to merge and asked me to do the following:
git fetch origin master
git checkout develop
git merge FETCH_HEAD
git commit
git push origin HEAD
And this happens after I have 'pushed' out my commits, making me confused at times. Then I realized that it is asking me to re-add and re-commit in the additional 3 new items. So does this means I must ensure that the items and contents between these 2 branches of mine should be the same as always? I have always used git pull/fetch but will there be a better way for me to make sure?
What this means is that GitHub would like to merge your PR branch into master, but it can't, because there are conflicts. As you've discussed in the question comments, the best way to deal with this (usually) is to merge your master branch into develop on the command line. That will show you the conflicts and ask you to resolve them. Once you've completed and pushed that merge, the PR will be mergeable back into master using the green button on GitHub.
You could simply merge your deploy branch into master (which I realize sounds a bit more sensible). In that case, you'd be bypassing the PR entirely. You'd have to close the PR "unmerged", and separately you'd manually push the merge commit to master.
By doing it the first way,
you make a better audit trail by merging to master on GitHub, using the PR;
you give your team a chance to review your code after the merge, before it lands on master; and
if you have automatic tests (such as Travis CI or CircleCI) which check PRs, you give them a chance to run your merged code as well.