2017-09-19 14 views
1

私のローカルdevelopブランチをいくつかのコミットにリセットし、ローカルのdevelopブランチをリモートにプッシュしたいので、リモートのHEADもまたわずかなコミットにリセットされます。言い換えればリモートブランチをいくつかのコミットにハードリセットします

、私はそうのようでした:

UserName path/ (develop) 
$ git reset --hard {CommitIdOfAFewCommitsBehind} 
Your branch is behind 'origin/develop' by 14 commits, and can be fast-forwarded. 
    (use "git pull" to update your local branch) 
nothing to commit, working tree clean 


$ git push origin develop 
To https://github.devtools.merrillcorp.com/Javelin/wopi-poc.git 
! [rejected]  develop -> develop (non-fast-forward) 
error: failed to push some refs to 'https://github/repo.git' 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Integrate the remote changes (e.g. 
hint: 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

は、どのように私は、リモートでも、私が欲しいコミットIDに行かせるのですか?

答えて

1

developブランチのハードリセットを実行したときに、そのブランチの履歴が書き換えられました。これの副作用の1つの副作用(別の副作用は後述)は、Gitは新しい切り捨てブランチをリモートのバージョンにリンクする方法を知らないので、もはやあなたからのプッシュを受け入れることはできません。だから、あなたは上書きするプッシュを強制する必要があります。

git push --force origin develop 

私は、このブランチを共有することを起こるdevelopの歴史を書き換えることも、あなたのチームの誰のための問題を引き起こすということです別の副作用を、言及しました彼らが引っ張るとき。

ほとんどの場合、共有ブランチでは、ハードリセットを実行してコミットするのではなく、git revertを実行することをお勧めします。一連のコミットを元に戻す方法については、ドキュメントまたはスタックオーバーフローを確認してください。

+0

緑色のチェッカーに9分。 –

関連する問題