2017-02-25 18 views
1

複数のコミット(既にorigin/masterにプッシュされている)からコミットしようとしています。GIT rebase - 複数のコミットを履歴に残す

私はこのチュートリアルからそれをしようとしています: https://feeding.cloud.geek.nz/posts/combining-multiple-commits-into-one/

$ git log --oneline 
c172641 Fix second file 
24f5ad2 Another file 
97c9d7d Add first file 
we can combine the last two commits (c172641 and 24f5ad2) by rebasing up to the first commit: 

$ git rebase -i 97c9d7d 
and specify the following commands in the interactive rebase screen: 

pick 24f5ad2 Another file 
squash c172641 Fix second file 
which will rewrite the history into this: 

$ git log --oneline 
1a9d5e4 Another file 
97c9d7d Add first file 

Iが原点/マスターにプッシュされるまでこれが、良い作品。

$ git pull 
$ git push origin master 
$ git log --oneline 

RESULT IS: 
******* Merge branch master... 
******* THAT REBASE name... 
c172641 Fix second file 
24f5ad2 Another file 
97c9d7d Add first file 

しかし、私はこの結果をしたい:

$ git log --oneline 
1a9d5e4 Another file 
97c9d7d Add first file 

が可能ということですか?

+1

"a dog"の助けを借りてください: 'git log --all --decorate --oneline --graph'を実行してください。マージ後に「すべて」の部分を省略することができます。 * 'git pull' *を使用しないでください。まず' git fetch'を使い、次にDOG、* then * merge * if * DOGがOKだと言うことを覚えておいてください。 :-) – torek

答えて

1

この場合、あなたはプッシュしたい場合があります代わりに&プッシュプル

$ git log --oneline 
1a9d5e4 Another file 
97c9d7d Add first file 

$ git push -f origin master 

予告:rebase + force push公共の枝に注意して使用し、歴史を上書きします。

+0

私はそれを試してみましたが、私は "すべてが最新です" –

+0

'git stash'を最初に' git reset --hard 1a9d5e4; git push -f origin master'? – Xlee

+1

ありがとう、あなたの押し付け力が働きます!私はrebaseの途中にいることに気付かなかった...私は矛盾を解決し、git rebaseを使い続ける - そしてそれをマスターに強制する。 –

関連する問題