yuuho.wiki

カオスの欠片を集めて知恵の泉を作る

ユーザ用ツール

サイト用ツール


tips:git:start

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
tips:git:start [2024/01/28 13:15] – [その他] yuuhotips:git:start [2025/06/23 19:31] (現在) – [branch を扱う] yuuho
行 1: 行 1:
 ====== Git ====== ====== Git ======
 +=== 未整理 ===
 +
 +  * git addでステージングしたファイルをアンステージング(キャンセル)する
 +    * https://mrgoofy.hatenablog.com/entry/20100910/1284068244
 +  * 【Git】git管理下のファイルをリネームしたらdeletedとuntrackedの2つになってしまった時
 +    * https://qiita.com/arubaito/items/952cfdfa048980c88562
 +
 +
 +
  
 === 変更を無かったことにする === === 変更を無かったことにする ===
行 19: 行 28:
 === GitHubに登録している鍵の把握 === === GitHubに登録している鍵の把握 ===
 <code>https://github.com/${USERNAME}.keys</code> <code>https://github.com/${USERNAME}.keys</code>
 +
 +
 +==== git diff ====
 +
 +  * workdir (現在の状態)
 +  * staging (add)
 +  * repository (commit)
 +
 +  * <code>git diff</code> は workdir と staging の比較。\\
 +  * <code>git diff --cached</code> または <code bash>git diff --staged</code> は repository と staging の比較。
 +
 +
 +見やすさのために
 +<code>git diff --stat</code>
 +
 +==== コミットを作らず差分の共有をする ====
 +<code bash>
 +# パッチファイルを作るとき(working vs staging)
 +git diff > hoge.patch
 +## ↑は staging と workingdir の比較
 +## 前回 commit と workingdir を比較する場合は
 +git diff HEAD > hoge.patch
 +# パッチを適用するとき(コミットを作らず working に展開)
 +git --git-dir= apply -p1 hoge.patch
 +# または
 +patch -p1 < hoge.patch
 +
 +# パッチを戻すときは
 +git --git-dir= apply -R -p1 hoge.patch
 +## というように -R オプションを付ければよい。
 +</code>
 +
 +特定のディレクトリ以下について調べる場合は ''git diff --relative=hogedir'' で指定。
 +
 +patch も base64 で共有するのが良いかも。空白などの情報が大切みたい。
 +
 +
 +
 +==== bundle を使ってコミットを共有する ====
 +
 +以下のような流れで実行する  
 +
 +  * 最初に現在の状態を bundle にする。 <code bash>git bundle create v00_first.bundle master</code>
 +  * 他の環境で bundle を復元 <code bash>git clone v00_first.bundle repo_name</code>
 +    * 場合によっては ディレクトリに入ってから ''git pull origin master'' しないといけない?
 +  * 作業している環境で新しいコミットを作る <code bash>git add hogehoge
 +git commit -m "hogehoge"</code>
 +  * 差分だけを bundle 化。<code bash>git bundle create v01_diff.bundle HEAD~1..HEAD</code>
 +  * 別環境で差分 bundle を pull <code bash>git remote add diff_commit /path/to/v01_diff.bundle
 +git pull diff_commit HEAD</code>
 +
 +
 +
 +
  
  
行 98: 行 161:
 === 設定を確認する === === 設定を確認する ===
 <code bash>git config --get hoge.fuga.piyo</code> <code bash>git config --get hoge.fuga.piyo</code>
 +
 +=== 設定を消す ===
 +<code bash>git config --unset hoge.fuga.piyo</code>
  
  
行 169: 行 235:
 git commit -m "取り込み" git commit -m "取り込み"
 </code> </code>
 +
 +===== コマンド =====
 +
 +==== add したものの確認 ====
 +<code bash>git diff --cached</code>
 +
tips/git/start.1706447711.txt.gz · 最終更新: 2024/01/28 13:15 by yuuho