We have two branches: develop
and master
.
For some reason when I create a PR of develop
--> master
. It shows a whole list of previous commits and changes even if I've made only a single line change in develop
.
Also, it will say "Can't automatically merge" when from the command line I'm able to merge develop
into master
without a problem.
Any idea what might be going on? Previously it was working fine for us.
EDIT: Here's what it looks like when we try to merge develop
to master
. Only the most recent commit is new. The others were merged previously: And the output of git log --oneline --decorate --all --graph
Have one commit per logical change and one major feature per pull request. When you submit a pull request, all the commits associated with that pull request should be related to the same major feature.
To exclude certain files from appearing in pull requests: In the repository containing the pull request, click Repository settings > Excluded files in the Pull Requests section. In the Patterns field, enter patterns to exclude from pull request diff views. Click Save.
This error occurs when a push directly to a branch bypassing review contains more commits than the server is able to validate in a single batch.
Your git log shows that there is a lot of commits in the develop
branch that don't exist in the master
branch. The pull request correctly shows a list of these commits, that can be merged into the master
branch.
To list all commits from the develop
branch that are not part of the master
branch you can use the command git log master..develop
. This should match the list you see in the pull request.
From your git log it looks like develop
has been merged into master
previously. But since these merge commits are no longer in the master
branch, is it possible that someone have done a reset of the master branch to an eariler state? Possibly to roll back changes if you have a deployment to an environment synced to the master
branch?
To get master
in sync with develop
again:
develop
and pull
to make sure the branch is up to datemaster
develop
into master
master
branchNow master
will be in sync with develop
again and the list of commits in develop
that master
is lacking should be empty. List these commits with git log master..develop
. Your next pull request will only contain the commits you do after this merge.
If you want to investigate further how you ended up in this state you can use reflog
to see what changes that have been made to the master
branch. Fore example if one of the more recent commits in develop
previously has been part of the master
branch.
git reflog master
If you want to do this you can do it before you merge the branches so you can see how the history looked before the fix.
I am not sure if I got the op correctly. As I understood you have a single commit in the development
branch so here is my try. I am considering the problem that your development branch is not in sync with master
revert back the development branch commit while keeping the local changes git reset --soft HEAD^ # Assuming the last commit is yours
At this point your local changes will stay in your machine as-is
Now push this to git .. you may try force push at this point. You can take help from here Rolling back a remote Git repository
Stash the local changes so that you can get these changes in future: git stash
At this point your development branch is clean and has no local changes
Now switch to master branch and update it with remote. git checkout master & git pull origin master
Switch to development branch and update it with remote. git checkout development & git pull origin development
merge the master to it. git merge master
At this point your development branch is in sync with master but locally
Push the development branch to remote server: git push origin developent
Now you can go to the github and raise PR and see if still shows difference. It should not show any such difference if above steps works with no problem.
Now take back your local changes that you stashed in step #2. git stash pop
Now commit it and push to the development branch and see the PR.
If Everything works fine then it should show the correct diff. git clean
also might be helpful after step #2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With