You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Git のあるファイルの全履歴をダウンロード(ローカルの任意のフォルダに取得)するスクリプトの存在をご存知でしたら、その情報を教えて頂けないでしょうか。
または、そのスクリプトを作成するためのアイデアがあれば教えてください。
何卒、宜しくお願い致します。
アトラシアン株式会社の向井です。
のご質問の文脈でご回答します。「 リポジトリ上の 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.