Home > front end >  Git branch suddenly became master
Git branch suddenly became master

Time:01-19

I'm keen to understand what happened. We created a git branch, after the work was done we created a PR and it was ok. Then locally I changed the branch to be master and started working again. Then I realized that the PR has all commits "REMOVED" and now master is equal to the branch that was created! We had a setting in BitBucket to forbid any changes to the master branch, I would like to know what and how it happened.

enter image description here enter image description here

Updates based on the comment:

  1. The strategy we use is "Squash, fast-forward only"
  2. I asked a guy to merge "master" into the branch, but it looks like master was merged into a branch. Is that possible with a setting Prevent changes without a pull request?
  3. In order to fix that, I created a new branch from master. Reverted all changes, created a PR, merged that PR. Now master looks like it should, but! I open that crooked PR and what I see is Shchukin, Petr remotely merged the pull request from xreg-3170/Link-foreign-key-transfer-institution-mapping-and-sis-integration-table-by-grantee-tenantId to master How did I remotely merged that branch?

CodePudding user response:

This looks like a fast-forward. It's a merge strategy that Git will pick if the branch is a simple descendant of master. No merge is necessary.

For example, let's say your repo looks like this.

A - B - C - D [master]
             \
              E - F - G [branch]

When you merge branch into master, no merge is necessary. Git simply moves master to where branch is.

$ git merge branch

A - B - C - D - E - F - G [master]
                          [branch]

Bitbucket offers this as a merge strategy. It may be the default.

I prefer disallowing fast-forwards and always requiring a merge commit. This makes it clear the work was done as a unit, and it provides a place to document the PR and issue # for reference later.

$ git merge --no-ff

A - B - C - D --------- M [master]
             \         /
              E - F - G [branch]

Then I realized that the PR has all commits "REMOVED"...

I haven't used BitBucket, but here's my guess. Since master and the PR branch are now at the same commit there are no differences. BitBucket is communicating that as the previous differences having been "removed".

BitBucket knowledge base as How to find all added or removed commits from Pull Request Updates? which might be useful to verify what happened.

  • Related