私たちは git を使用し、master ブランチと developer ブランチを持っています。新しい機能を追加してから、コミットをマスターにリベースしてから、マスターを CI サーバーにプッシュする必要があります。
問題は、リベース中に競合が発生した場合、リベースが完了した後、リモート ブランチをプルするまで、(Github の) リモート開発者ブランチにプッシュできないことです。これにより、コミットが重複します。競合がない場合は、期待どおりに動作します。
質問: リベースと競合の解決後、重複したコミットを作成せずにローカルとリモートの開発者ブランチを同期するにはどうすればよいですか
設定:
// master branch is the main branch
git checkout master
git checkout -b myNewFeature
// I will work on this at work and at home
git push origin myNewFeature
// work work work on myNewFeature
// master branch has been updated and will conflict with myNewFeature
git pull --rebase origin master
// we have conflicts
// solve conflict
git rebase --continue
//repeat until rebase is complete
git push origin myNewFeature
//ERROR
error: failed to push some refs to 'git@github.com:ariklevy/dropLocker.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
// do what git says and pull
git pull origin myNewFeature
git push origin myNewFeature
// Now I have duplicate commits on the remote branch myNewFeature
編集
したがって、これはワークフローを壊すように思えます:
developer1 は myNewFeature に取り組んでいます developer2 は hisNewFeature に取り組んでいます 両方とも master をメイン ブランチとして使用します
developer2 は myNewFeature を hisNewFeature にマージします
developer1 はリベースし、競合を解決してから、myNewFeature のリモート ブランチに強制的にプッシュします
数日後、developer2 は myNewFeature を hisNewFeature に再度マージします
これにより、他の開発者は developer1 を嫌うようになりますか?