2017-01-26 5 views

答えて

2

"最後の訪問日"の検索方法はわかりません。ブランチをリストする方法がしかしあり、(逆)時系列にそれらを訪問した:


gitが@見つけ出し検査することによってなど、{ - 1}、@ { - - 2}、@ {3} reflog、および保持する線の表示はcheckout: moving from aaa to bbbのようになります。

あなたが同じ行動のあなたの方法をgrepすることができます。

git reflog | grep -o "checkout: moving from .* to " |\ 
    sed -e 's/checkout: moving from //' -e 's/ to $//' | head -20 

コメント

# inspect reflog : 
git reflog |\ 

# keep messages matching 'checkout: ...' 
# using -o to keep only this specific portion of the message 
grep -o "checkout: moving from .* to " |\ 

# remove parts which are not a branch (or commit, or anything) name : 
sed -e 's/checkout: moving from //' -e 's/ to $//' |\ 

# keep only last 20 entries 
head -20 
+1

優秀、私は探していた以下の方向性ありがとう: 'git reflog | sed -n 's /.* checkout:。*から\(。* \)/ \ 1/p'に移動します。 awk '!x [$ 0] ++' ' gitエイリアスとして追加されました! 説明:上記のように、sedはすべてのreflog行から「[X]に移動」します。いくつかのブランチはこのリストに複数回出現するので、awkはエントリをユニークにしますが、リストを 'uniq'や' sort -u'のようにソートする必要はありません。 – astgtciv

+0

「awk」トリックありがとう!私ははるかに複雑な方法を使っていました( 'cat -n'を使い、一意のブランチ名を保持してから行番号順にソートしています...) – LeGEC

関連する問題