I am trying to do a 'git pull --rebase', but I don't see any remote changes. When I do a 'git status' I see ' Your branch is ahead of 'origin/master' by 12 commits.'
But I am current on my 'dev' branch, not master.
$ git branch
master
* dev
And my 'dev' branch should track 'remotes/origin/dev'.
All I want is I am working on 'dev' and I want to get remote changes on remote dev.
But I did 'git pull --rebase' which some how pull remote 'master' changes to my 'dev' branch.
Can you pleases tell me how can I recover from my situation?
remove the changes I pull in from remote 'master' branch mistakenly (after i did 'git pull --rebase')
pull in the changes on remote 'dev' branch on to my 'dev' branch.
Thank you.
It sounds as if your dev branch was originally based on origin/master
instead of origin/dev
, or somehow dev
has been changed to track origin/master
anyway. You can check this with:
git config branch.dev.merge
If that says refs/heads/master
instead of refs/heads/dev
you can change the upstream branch for your dev
branch with:
git checkout dev
git branch --set-upstream dev origin/dev
Then, to fix your branch, I would:
dev
branch with git checkout dev
git status
is cleangit branch dev-wrongly-rebased
git reflog
to find the commit before you rebased onto origin/master
dev
to that point git reset --hard COMMIT-BEFORE-BAD-REBASE
git rebase origin/dev
My preference when rebasing is always to do it in two steps, e.g.:
git fetch origin
git rebase origin/dev
... since I think that's less error-prone than git pull --rebase
. I hope that's of some use.
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