I have a feature branch that should have all its commits as ahead of master, however when I try to merge master into my feature branch like so:
(feature)$ git merge master
All of my changes in the feature branch gets removes. I also tried to use rebase but I keep getting the same result.
(feature)$ git rebase master
First, rewinding head to replay your work on top of it...
Fast-forwarded feature to master.
(feature)$ git checkout master
(master)$ git merge feature
Already up-to-date.
I only did the git merge feature
to test if the rebase worked, which it didn't as it is Already up-to-date.
It is like somehow at some point my feature branch got behind master, I am not sure how and when this happened. it might be that the feature branch was merged to master branch then removed with a new commit, however when I am done with the feature branch I would like to add it to master at some point in the future when I want to deploy it.
My question is, how can I move all the commits that where made to the feature branch ahead of the master branch
Or can I recommit all the changes that are currently in feature branch after I do a git merge master
C1(feature branch) <-- C2(merge master into feature) <-- C3(recommit C1)
Notes:
- all of what I tried to solve this is on my local machine.
- I work in a team.
Update
I figured out what exactly happened, somebody created a new branch (feature-B) from feature branch instead of creating one from master branch and then merged feature-B into master branch:
(feature)$ git checkout -b feature-B
...
...
...
(feature-B)$ git checkout master
(master)$ git merge feature-B
(master)$ git push
and then after figuring out the problem, the same developer reverted the merge of feature-B into master