-1

「master」というブランチで作業していました。誰かがオリジンから削除したため、変更をコミットできない奇妙な状態になりました。それらを新しい「安定した」ブランチにコミットしたいと思います。

私はstackoverflowのいくつかの指示に従ってみましたが、今は本当にめちゃくちゃです。

$ git log --oneline --decorate --graph --all -10
* 4b2b148 (HEAD, origin/stable, stable) move from master branch
| * 1be25fe (origin/master, origin/HEAD, next, master) require pcre to prevent regular expression weirdness

1be25fe は安定版に適用したいコミットです。4b2b148 は私が間違って作った奇妙なものです。1be25fe を安定版に置き、4b2b148 を完全に削除するにはどうすればよいですか?

4

1 に答える 1

1

1be25fe に戻すには、次のコマンドを実行する必要があります。これにより、HEAD が 1be25fe に戻ります。次に、プッシュを実行して、そのアップストリームをプッシュできます。

git reset --hard 1be25fe # revert back to 1be25fe
git status               #to check to see that it has reverted correctly, and see if there are any other issues.
git push origin stable   #push the changes and recreated the branch upstream

// 編集

your 'tip' is behind エラーを回避するには、-fパラメーターをプッシュに追加します。このパラメーターは、リモート リポジトリでの変更を強制します。私は以前に同じ問題を抱えていましたが、完全に機能しました。

git push -f origin stable

// 編集 2

実際にコミットを削除したい場合は、リベースを検討する必要があります: http://git-scm.com/book/en/Git-Branching-Rebasing

// 編集 3

変更を 4b2b148 にマージするには、次の手順を実行する必要があります。

git checkout -b important_changes origin/stable # branch off from the current state
git cherry-pick 4b2b148 # retrieve the commit containing the changes and insert it ahead of 1be25fe
git checkout stable # switch back to the older branch
git merge important_changes # merge in the important changes
git commit -am 'merged important changes' # commit the changes
git push origin stable # push the branch to master
git branch -d important_changes # remove the temp branch.

important_changes警告: と の両方をマージすると、マージの問題が発生する可能性がありますstable。押す前に、それらが固定されていることを確認してください。

于 2013-07-02T21:57:09.123 に答える