Reputation: 425
I am working with two branches in git, named 'develop' and 'feature'. Feature is my own working branch and develop is used by the whole group. I initially cloned develop into a local repository and created the feature branch from develop:
git checkout -b feature
I made multiple edits to the feature branch, including making new files, and pushed the branch the the remote repository:
git push origin HEAD
The develop branch has undergone multiple changes by other group members since I first cloned it.
I am now trying to merge my feature branch in Bitbucket with the group develop branch. When I try to create a pull request, I get a message under the diff tab stating 'There are no changes'. Under the commit tab, I get 'no commits found'.
If I attempt to merge the develop branch into the feature branch, however, many changes and a detailed commit history are reported. Bitbucket flags all the changes I have made in the feature branch for deletion.
I have tried creating a new branch in the local repository from the develop branch, and merging my changes into this branch:
git checkout develop
git pull
git checkout -b new_branch
git merge feature
I get the message 'Already up-to-date.' and none of my changes are merged.
Can anyone suggest why my branches are failing to merge?
Upvotes: 0
Views: 698
Reputation: 425
One of my colleagues had merged my feature branch into the develop branch, reverted the merge, then made their own changes to the develop branch. Removing my changes was therefore part of the develop branch history, and was being enacted when I tried to merge feature into develop.
To get around this, I cloned a clean copy of the develop branch and reverted this branch back to the commit just before my feature branch was un-merged. I then merged the reverted branch into the local copy of the feature branch. After resolving conflicts and committing changes, I was able to push my feature branch to the remote server and merge it into the develop branch.
So, the problem arose because git keeps a record of changes created by reverts as well as changes created by merges.
Upvotes: 2