4

OSX では、多くの場合git log、コミットを見つけるために にアクセスし、通常は数回戻ってマウスでコピーし、そこからリベースします。

マウスを使用したり覚えたりせずに、どうすれば簡単にこれを行うことができますか?

4

4 に答える 4

3

最初の数文字/数字を覚えるだけです。

Git は、リベースするために完全なハッシュを必要としません。最初の数文字だけが必要です。

例えば:

git log

コミット a64da17d5f674973ead1a0bcf0196f292313893f

コミット 11be728caad156d5cb6ce336747aab4e5e3417b0

コミット e63760a22b4e5919961e409a66fac09176a574b6

コミット 3521260b7d04fc92eaeb9c70fa46999dc1ecda3d

コミット ba4868bd6a6b4e9d9a77f66e77be189d37b1ffe8

(余分なコミットのものを差し引いたもの)

ここで、2 番目の文字が必要だとしましょう11be728caad156d5cb6ce336747aab4e5e3417b0 。最初の数文字をリベースするだけです。

git rebase 11be

詳細情報: 技術的には、git はハッシュの一意の開始のみを必要とします。したがって、この場合、git rebase 11 で始まるコミット ハッシュは他にないため、これで十分です。ただし、極端な場合には、4 ~ 5 文字を超える文字が必要になる場合があります (ほとんどありません)。

Also, feel free to use git log -n to get only the last n number of commits. By keeping this to a low number, the commit is still usually on your screen when you call rebase, so you have no need to memorize. Just manually copy the first couple characters. Hint: If git flushes the log output once you hit 'q' to quit, you can use the command git --no-pager log -n to get the output to "stick".


For added info on git and rebase, if you knew you wanted to rebase exactly 4 commits, you could just use the HEAD reference. Your current commit is HEAD and 1 commit ago is HEAD~1 etc. For example:

git rebase HEAD~4

would set 3521260b7d04fc92eaeb9c70fa46999dc1ecda3d as the new HEAD (since we are rebasing on ba4868bd6a6b4e9d9a77f66e77be189d37b1ffe8)

于 2014-09-17T20:47:14.477 に答える