差分ファイルの出力
ログの取得
git log --oneline
ブランチ内
[from_commitID]・・・変更前のID Version1
[to_commitID]・・・変更後のID Version2
git archive [to_commitID] `git diff --name-only [from_commitID] [to_commitID] --diff-filter=ACMR` -o _diff.zip
例)
git archive 94958e0 `git diff --name-only 1b23c9b 94958e0 --diff-filter=ACMR` -o _diff.zip
ブランチ間
- gitでブランチ間の差分ファイルを抽出 masterの変更も抽出してしまう。 masterブランチ以外に移動して、下記のコマンドを実行する。
-- falseにすると、git statusで変更ファイル一覧を表示するときに、
-- 日本語のファイル名が文字化けしないでちゃんと表示される。
git config --bool core.quotepath false
git archive --format=zip --prefix=_diff/ HEAD `git diff master --diff-filter=ACMR --name-only` -o _diff.zip
指定ログの状態に戻して、また元の状態に戻す
git branch --contains=HEAD -- で現在のブランチを確認
git log -- で戻りたいコミットを確認
git checkout [commit] -- で、作業ディレクトリが指定したコミットの状態になる。
必要なファイルをコピーする。
git checkout [branch] -- で最初の元の状態に戻る。
branch
- master から作業中ブランチを生やしたベースコミットから差があるファイルを列挙
$BASE=git show-branch --merge-base master HEAD
git archive --format=zip --prefix=_diff/ HEAD `git -c core.quotepath=false diff $BASE HEAD --name-only` -o _diff.zip
- ブランチの一覧を取得
bash git branch -a
# --pruneオプションをつけると、fetchやpullする際に自動的にリモートで削除されているリモートブランチを削除してくれる。
fetch --prune
$ git fetch --prune
x [deleted] (none) -> origin/hoge
or
git remote pruneを実行する
$ git remote prune origin
x [deleted] (none) -> origin/hoge
ローカルブランチとremotes/*が一致しない場合は、手動でローカルブランチを削除します。
# どちらも同じ
$ git branch --delete [ブランチ名]
$ git branch -d [ブランチ名]
$ git branch -a
develop/112
develop/114
develop/115
develop/116
* master
remotes/origin/HEAD -> origin/master
remotes/origin/develop/116
remotes/origin/develop/117
remotes/origin/master