blog.sowatchasayin

Rails etc.

git commit --amendはpushしたらやっちゃダメ

commitに「やっぱり」をかけたい時、ありますよね。
そんな時はgit commit --amendです。直前のコミットにワークツリーの変更を後乗せして、さも元々そうだったかのように見せることができます。
さてそれをpushするときどうするか…。普通にやるとgitに怒られます。

そこで質問
How do I push amended commit to the remote git repo?

--forceをつければOKです。でも誰かが「やっぱり」前のコミットをベースに変更しているかもしれないから、やっちゃダメですって話。

I actually once pushed with --force to git.git repository and got scolded by Linus BIG TIME. It will create a lot of problems for other people. A simple answer is "don't do it".

because if someone already got your changes, then when they try to pull again, it might fail.


何にせよ、多くの場合、「やっぱり」はよくない結果を生みますね。あと--forceも。
意思決定、合意形成はどこに行っても大事ってことで。

No comments:

Post a Comment

Author

Fujimura Daisuke
http://fujimuradaisuke.com

Labels