Reputation: 984
I made a mistake and pushed changes to master when it should have been pushed to develop. Whoops!
So, I pushed the changes to develop and removed the changes from master.
Unfortunately, this leads to GitHub thinking master is one commit ahead of develop when develop is the one ahead of master.
How can I make GitHub understand that develop is the branch with the newer content so the new changes won't be overridden in a future pull request?
Edit:
I removed the changes in master by pulling it, removing the last commit using
git revert -m 1 <SHA of commit>
, and pushed it to master
Edit 2:
It seems I was unclear. The develop branch has the changes that I want to implement to master in the future.
However, the master branch has the commits that I applied to develop plus an additional commit, which cancelled out the changes that develop has.
I want the changes in develop to be applied to master in the future. However, master believes it is ahead because I cancelled out the changes that are implemented in develop.
Therefore, the develop branch is considered to be one commit behind and 0 commits ahead since master has the changes from develop plus a commit that reverses the changes from develop.
From my understanding, git rebase would 'fast-forward' develop to master. However, this would be unwanted since this would remove the changes that master needs to have in the future due to the above explanation.
Upvotes: 1
Views: 108
Reputation: 16043
This is a concept of git where a branch is both ahead & behind another branch.
Since you removed the unwanted commits from master
but making 1 more commit (which is not present in develop
branch), this means that there is 1 commit that is present in master
and absent in develop
branch. Clearly, master
is 1 commit ahead of develop
.
Similarly, there must be some commits (say n), which are present in develop
and yet not present in master
- this means that develop
branch is n
commits ahead of master
.
So you master
is both ahead (1 commit) & behind (n commits) of develop
branch.
To resolve this, merge master
into develop
branch.
After Edit :
To resolve this, get the lastest commit id which you think belongs correctly in the master branch (one just before the develop branch commits). Say <c1>
. Then do the following:
git reset --hard <c1>
This will remove the merge and unmerge commits, both.
Upvotes: 1