アトラシアン株式会社の向井です。
のご質問の文脈でご回答します。「 リポジトリ上の test.txt というファイルを、 test.txt.<ハッシュ値> というファイルとして、リポジトリの作業ディレクトリ外に保存する」というシナリオであれば、一つの例としては、以下のような手順であれば実現できるかと思います。
1. git log コマンドを利用し、コミットの履歴を取得して ファイルをコピーするコマンド文字列に変換します。具体的にはShellコンソールにて
git log test.txt | grep 'commit ' | awk '{print "git checkout " $2 " && cp test.txt ../test.txt." $2 }'
を実行します。
2. 上記で以下のような文字列が得られるはずですので、その文字列をコマンドとしてすべて実行します。
git checkout <ハッシュ値1> && cp test.txt ../test.txt.<ハッシュ値1>
git checkout <ハッシュ値2> && cp test.txt ../test.txt.<ハッシュ値2>
....
以上、あくまでアイデアとしてですが、よろしければご活用ください。
アトラシアン株式会社 向井様
ご回答誠にありがとうございます。
添付ファイルの様に、向井様に教えて頂いたコマンドの結果を"test.bat"ファイルに出力しましたが、このファイルの内容を確認すると全て改行がなく1行で出力されていました。
各行を改行させる方法と、作成したバッチファイルをSourceTree上で実行させる方法ご存知でしたら教えて頂けないでしょうか。
何卒、宜しくお願い致します。
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
以下のように、awkコマンドの最後に改行コードを含める形ではいかがでしょうか?
template1.cというファイルをチェックアウトしたいようでしたら例えば以下のようなコマンドになります。
git log template1.c | grep 'commit ' | awk '{print "git checkout " $2 " template1.c && cp template1.c ../template1.c." $2 "\n"}'
また、上記はSourceTreeというよりはGitコマンドの組み合わせのみで実現していますので、コマンドプロンプト等のコンソールでご実行ください。
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
アトラシアン株式会社 向井様
"\n"だと LFLF になってしまいましたので、以下の様に "\r" にしましたら CRLF で出力され、メモ帳で「test.bat」を開くと各行改行されました。
$ git log template1.c | grep 'commit ' | awk '{print "git checkout " $2 " template1.c && cp template1.c ../template1.c." $2 "\r"}' > test.bat
ただ、以下の通り、SourceTree のターミナル上でしたら、LF だけでも問題なくファイルをコピーすることが出来ました。
$ git log template1.c | grep 'commit ' | awk '{print "git checkout " $2 " template1.c && cp template1.c ../template1.c." $2 }' > test.sh
$ ./test.sh
ご回答誠にありがとうございました。
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
お知らせありがとうございます。お役に立てまして何よりでございます。
他にも弊社製品に関連してご不明点がありましたらお気軽にコミュニティをご利用ください。
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.