问题
So I am in branch feature
. And I want to rebase w/ branch master
.
git rebase master
And it says that feature
branch is up-to-date. Of course it is because master
branch hasn't changed — it is the same as in moment when I create feature
branch from it.
Actually it is not. All I need is to do pull in master
branch.
git checkout master
git pull
git checkout feature
My question: can't I update master
branch w/o checking-out to it?
I tried from feature
branch:
git pull origin master master
...but it updated feature
branch (not what I wanted to) and it has commits “in furure“ in it.
Thanks in any advice! :)
回答1:
git push . origin/master:master
the dot refers to the current repository. This will stop you from doing non-fast-forward updates. If you still want to that, you can add the -f
or --force
options.
回答2:
If you are sure that you don't have anything on master
that you want to keep you can do:
git fetch
git update-ref refs/heads/master origin/master
If you are doing this regularly, though, there is really no point in keeping your master branch. Just use the remote tracking branch (origin/master
) for merges, diffs, rebases, etc. as it is updated automatically by git fetch
.
来源:https://stackoverflow.com/questions/13580484/update-not-the-current-branch-in-git