2

この質問を検索しようとしましたが、誰も私の質問に答えませんでした。

例を挙げさせてください:
git サーバーに 2 つのブランチがあります。

origin/master
origin/feature

ブランチ 'feature' は 'master' から分岐しています。他の全員が 'master' で作業しているため、影響を与えたくないので、ローカルで 'feature' を分岐してリモートにプッシュしました。

'master' には毎回コミットがあるので、2 日後、'feature' のコードを最小限にしたいのですが、'origin/master' から 'origin/feature' にコードをマージする方法はありますか?次に、最小の「原点/機能」を引っ張るだけです。

私は試した

git checkout origin/feature
git merge origin/master
git status # you would see that this is the lease code with lots of commits
git checkout feature
git pull

しかし、 i の後git pull、私は何も得られませんでした。それらの最小のコミットでさえ失われました。

そのため、ローカルではリモートorigin/featureのイメージにすぎないことに気付きました。origin/featureだから私のやり方はうまくいかなかった。

私の要件を満たす他の方法は

git checkout feature
git stash
git pull origin master:feature
git push origin feature:feature # or just [git push]
git stash pop stash@{0}

そして、これが私が今使っている方法です。

何もプッシュせずに、これらの2つのリモートブランチを直接マージできる方法があるのだろうか?

4

1 に答える 1

1
#fetch latest changes in origin
git fetch origin

git checkout feature

#to sync feature with what you have now
git push origin feature

#merge locally, while you sit on feature
git merge origin/master
#now push the merge to the origin
git push origin feature
于 2015-07-13T19:30:32.223 に答える