Not see remote changes after 'git pull –rebase'
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.
2 Solutions collect form web for “Not see remote changes after 'git pull –rebase'”
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:
- Make sure that you’re on the
git checkout dev
- Make sure that
git statusis clean
- Create a branch to save where you were (for safety):
git branch dev-wrongly-rebased
git reflogto find the commit before you rebased onto
devto that point
git reset --hard COMMIT-BEFORE-BAD-REBASE
- Finally, do
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.
You can move the commits on top of the correct remote branch with
git rebase --preserve-merges --onto origin/dev start end
for a range of commits specified by start and end to be moved onto dev.
Then, set up tracking properly. If you want, you can edit the .git/config file and compare how traking is set up for each branch all at once and ensure consistent behavior.
From now on, of you are getting a new remote branch
git checkout -t origin/branch_name
Or if you are pushing a new branch to the remote
git push -u origin branch_name
These will set up traking as you want.
Hope this helps.