Gitコマンド
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfras...
-[[戻る>Git]]
--[[Gitの基本]]
--Gitコマンド
--[[インストール>Git#f825d4d1]]
*目次 [#pda27e8e]
#contents
*基本操作 [#t6467371]
-わざわざ、Gitコマンドを使う ≒ Linux上での操作を想定
-複雑な操作は、GitHub上で行う想定(マージはプルリクエスト...
-GitHubで認証を求められたら、https://github.com/settings/...
-試してみたが、俯瞰性能の低いCUIは使い難い。編集中は最低...
**インストール [#zacbd2ed]
***バージョン表示 [#j1060f65]
git --version
***インストール [#qbfa055f]
インストールされない場合はインストール
sudo apt update
sudo apt install git
**準備 [#m875bb31]
Gitにあるリポジトリを操作~
(testリポジトリのtestブランチ)
***clone [#d3cde2a4]
git clone https://github.com/daisukenishino2/test.git
cd test
***branch切替 [#x66ec82d]
-既存
git switch test
-新規
git switch -c your-task
**開発 [#bc235d98]
***編集 [#k4c56650]
nano README.md
***確認 [#teb2586c]
-変更のあったファイルを確認
git status
-それぞれの差分を確認
git diff
***追加 [#d48dd1fc]
ステージングに追加
-ファイル指定
git add README.md
-すべてのファイル
git add .
-間違った場合(作業ディレクトリに何の変更も加えることなく...
git reset
※ 基本的に1ファイル1ファイル指定したほうが良さそう。
***commit [#j950f480]
git commit -m "updated."
***pull [#n9f24272]
git pullコマンドはgit fetchコマンドとgit mergeコマンドを...
git pull origin <branch>
***push [#yec449a2]
pullしてpushすればコンフリクトはない。
git push origin <branch>
※ 任意の認証が必要になる。
*repository [#bcd73d11]
**clone [#md913091]
git clone は既存の git repositoryのclone (コピー) を作成...
-Git clone | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!clone
--既存の Git repositoryのコピーを作成する
--コピー元repositoryをポイントする origin という名称のrem...
--svn checkout と異なり、作業コピーがそれ自身で
---完全な git repositoryを構成する。
---履歴を持ってファイルを管理する。
-command
--local or remoteのrepositoryをcloneする。
git clone <repo>
--クローン先のdirectoryを指定してcloneする。
git clone <repo> <directory>
**repository間 [#p50d4a25]
***git remote [#pd21aa82]
-Git remote | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--他のrepositoryとの接続の作成、内容確認、削除を行う
--非短縮 URL への参照として使用可能な短縮名称として機能
***git fetch [#u260b8a6]
remote repositoryからfetchする。
-Git fetch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--remote repositoryからlocal repositoryにbranchをインポー...
--local branchとしてではなく、remote branchとして保存され...
--pullと異なりlocal repositoryにmergeする前に変更内容を確...
-commit
--remoteのすべてのbranchをfetchする。
git fetch <remote>
--remoteの特定のbranchをfetchする。
git fetch <remote> <branch>
***git pull [#r6fe7f69]
remote repositoryからpull(fetch & merge)する。
-Git pull | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--git fetch commandとそれに続く git merge commandをひとつ...
-command
--現在のbranchにremote branchをfetchして即時merge
git pull <remote>
--remote branchを現在のbranchにmergeする際に git [[rebase...
git pull --rebase <remote>
***git push [#ne215224]
remote repositoryへpushする。
-Git push | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--local repositoryからremote repositoryにbranchをエクスポ...
---localな変更の中央repositoryへの公開
---remote repository内で git merge master commandを実行す...
---push先は --bare フラグを指定して作成したrepositoryに限...
-command
--指定したbranchを <remote> にpushする
git push <remote> <branch>
--すべてのlocal branchを指定したremote repositoryにpush
git push <remote> --all
--すべてのlocal tagをremote repositoryに送る
git push <remote> --tags
*branch [#df55a0b8]
**branch [#tf3a027e]
branchする
-Git branch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!b...
--branch(独立な開発ライン)の作成
--作業ディレクトリやステージングエリア、プロジェクト履歴...
-command
--現在のbranchから<new-branch>をbranchする~
「作成するだけで、切り替えはしない」 ので注意
git branch <new-branch>
**checkout [#u1308258]
branchをcheckoutする(切り替える)。
-Git checkout | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!c...
--branchを切り替える。
--HEADが移動することで、使用するbranchが変更される。
-command
--既存branch <existing-branch> に切り替える。
git checkout <existing-branch>
--新規branch <new-branch> を作成して即時checkout
git checkout -b <new-branch>
--既存branch <existing-branch>から新規branch <new-branch>...
git checkout -b <new-branch> <existing-branch>
**merge [#u18db080]
branchをmergeする。
-Git merge | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!m...
--branch(分岐した履歴)を現在のbranchへ統合する手段
-command
--指定したbranchを現在のbranchにmergeする
git merge <branch>
-- 「早送り」可能であっても、常にmerge commitを作成してme...
git merge --no-ff <branch>
-参考
--merge commitとFast-forward merge - Qiita~
http://qiita.com/shyamahira/items/59ff8aa1cf7b893aab60
**削除 [#v5c058a3]
branchを削除する。
-mergeされたbranchを削除する
git branch -d <experimental>
-mergeされたかどうかにかまわず削除する
git branch -D <experimental>
*開発 [#w9a915cb]
**ステージング [#y7ac6e3e]
***git add [#td795c21]
作業ディレクトリ内の変更をステージングエリアに追加
-Git add | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!add
--個々のファイルの変更内容を次回commitの対象とすることを ...
--git commit を実行するまでは変更がは実際に記録されない。
-command
--<file> に加えられたすべての変更をステージして次回のコミ...
git add <file>
--<directory> 内のすべての変更をステージして次回のコミッ...
git add <directory>
--インタラクティブなステージングセッションを開始する。
git add -p
***git clean [#maa79d68]
作業ディレクトリから追跡対象外のファイルを削除する
-Git clean | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--通常の rm コマンド同様 git clean コマンドも元に戻すこと...
-command
--git clean の「予行演習」を行うコマンドで削除されるファ...
git clean -n
--追跡対象外のファイルをカレントディレクトリから削除する。~
ただし、.gitignore. で指定したファイルは削除しない。
git clean -f
--追跡対象外のファイルを指定したパスから削除する。
git clean -f <path>
--追跡対象外のファイルとディレクトリをカレントディレクト...
git clean -df
--追跡対象外ファイルと通常無視されるファイルをカレントデ...
git clean -xf
***git reset [#y5c171a9]
ステージングエリアをリセットする(ワーキングツリーは変更...
-Git reset | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
-command
--作業ディレクトリに変更も加えずに、指定したファイルをス...
git reset <file>
--作業ディレクトリに何の変更も加えることなくステージエリ...
git reset
--ステージエリアと作業ディレクトリをresetして直前のcommit...
git reset --hard
**commitの操作 [#ufb99886]
<commit> = commit の"SHA-1 id"
***git commit [#sd4b5e04]
変更のcommit
-Git commit | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!com...
--ステージされたスナップショットを取り込んでlocal reposit...
--スナップショットは常にlocal repositoryにcommitされ、他...
-command
--ステージされたスナップショットをcommit。
git commit
--commit メッセージ付きでcommit。
git commit -m "<message>"
***git reset --hard [#y5c171a9]
履歴を完全に戻したい(かつ単独作業中)
-Git reset | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--commit済みのスナップショットを削除する目的でも使用され...
--git revert コマンドは変更を元に戻す「安全な」方法
--コレに対し、git reset コマンドは変更を元に戻す「危険な...
--復元方法が無いため、ローカルな変更を元に戻す場合に限る...
-command
--現在のbranchの先端を <commit> の位置に戻した上でステー...
これにより、変更規模が小さく整理されたスナップショットを...
git reset <commit>
--現在のbranchの先端を <commit> の位置に戻した上でステー...
commit前の変更に加えて <commit> の後に行われたすべてのcom...
git reset --hard <commit>
***git revert [#j96c5e46]
指定したコミットを「打ち消す」新しいコミットを作る(履歴...
-Git revert | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--履歴を保全し、履歴の完全性とコラボレーションの信頼性を...
--commitがなかったものとするのではなくそのcommitによって...
-command
--特定のcommitのrevert
git revert <commit>
*確認 [#ed1a8ab6]
**branch [#l771f1ea]
***git branch [#t5e56642]
branchの確認
-Git branch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!b...
--一覧表示
-command
--local branchの確認
git branch
--remote追跡branchを表示
git branch -r
--local branchとremote追跡branchの両方のbranchを表示
git branch -a
--名称の変更
git branch -m <branch>
**ステージング [#b46c38af]
***git status [#c4ba7161]
statusの確認
-Git status | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!sta...
--作業ディレクトリとステージングエリア(ステージされたス...
---ステージされた変更内容、
---ステージされていない変更内容
---Git による追跡の対象外となっているファイル
-command
--ステージされたファイル、されていないファイル、追跡対象...
git status
**commit [#dde136ae]
***git log [#aa03bcf5]
logの確認
-Git log | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!log
--commit済みのスナップショットを表示するcommand
--commit済みの履歴 (commit履歴) のみが対象
---commit済み変更履歴の一覧表示
---それに対するフィルター処理
---特定の変更内容の検索
-command
--commit履歴全体をデフォルトの形式で表示
git log
--表示するcommit数を <limit> に制限する。
git log -n <limit>
--commit履歴を概観する(各々のcommitの内容を1行に圧縮して...
git log --oneline
--改変されたファイルおよびその中での追加行数と削除行数を...
git log --stat
--各々のcommitに対応するパッチ(commitの完全な差分情報)...
git log -p
*Rebase、Reset、Revert [#h1b9459f]
Rebase、Reset、Revert の違いと使い分け
**Rebase [#j203a3fa]
「履歴を綺麗にしたい」場合に使う(ローカルでのみ行うべき)
***概要 [#g5360a3f]
-ブランチの基点(親コミット)を変更することで、履歴を整理
-ブランチを最新の `main` ブランチに追従させる(の最新の状...
***動作イメージ [#z60b8dd4]
https://www.google.com/search?q=Rebase&udm=2
***注意点 [#g68d11bd]
-履歴を書き換えるため、リモートにプッシュしたコミットに対...
-既にリモートにpushしたコミットの履歴をrebaseで書き換えた...
--他の開発者のローカル履歴とリモートの履歴が不一致になり...
--リモートの意図しない履歴を書き換える可能性があり、また...
**Reset [#jde6ea7e]
「間違えてコミットした」場合に使う(ローカルでのみ行うべ...
***概要 [#le07b64f]
-指定したコミットに対して、現在のブランチを強制的に戻すコ...
-履歴を巻き戻すとともに、ワーキングツリーやインデックスの...
|モード|`git reset <commit>` の影響|h
|`--soft`|コミット履歴だけ戻し、インデックスやワーキング...
|`--mixed`(デフォルト)|コミットとインデックスは戻るが、...
|`--hard`|コミット、インデックス、ワーキングツリーすべて...
***注意点 [#b0a1d65c]
- `--hard` を使うと 変更が完全に消える ので、慎重に使うこ...
- リモートにプッシュ済みの履歴を変更すると他の開発者に影...
**Revert [#yc7d4458]
「リモートに影響を与えずに変更を取り消したい」(安全なの...
***概要 [#ef4308a4]
-履歴を維持しながら特定のコミットの変更を取り消すため、リ...
--指定したコミットを打ち消す「新しいコミット」を作成する...
--履歴を改変せずに変更を取り消すことができるため、安全な...
***注意点 [#m9c5025d]
--履歴が残るため、リセットのように「なかったこと」にはな...
--逆順にrevert(打ち消す「新しいコミット」)してもコンフ...
***比較表 [#c9211f1f]
|コマンド|目的|履歴の改変|影響範囲|h
|rebase|履歴を整理・ブランチを最新にする|する|ローカルの...
|reset|コミットを取り消す・巻き戻す |する|ローカルのみ(...
|revert|特定のコミットを打ち消す |しない|リモートでも安全|
終了行:
「[[.NET 開発基盤部会 Wiki>http://dotnetdevelopmentinfras...
-[[戻る>Git]]
--[[Gitの基本]]
--Gitコマンド
--[[インストール>Git#f825d4d1]]
*目次 [#pda27e8e]
#contents
*基本操作 [#t6467371]
-わざわざ、Gitコマンドを使う ≒ Linux上での操作を想定
-複雑な操作は、GitHub上で行う想定(マージはプルリクエスト...
-GitHubで認証を求められたら、https://github.com/settings/...
-試してみたが、俯瞰性能の低いCUIは使い難い。編集中は最低...
**インストール [#zacbd2ed]
***バージョン表示 [#j1060f65]
git --version
***インストール [#qbfa055f]
インストールされない場合はインストール
sudo apt update
sudo apt install git
**準備 [#m875bb31]
Gitにあるリポジトリを操作~
(testリポジトリのtestブランチ)
***clone [#d3cde2a4]
git clone https://github.com/daisukenishino2/test.git
cd test
***branch切替 [#x66ec82d]
-既存
git switch test
-新規
git switch -c your-task
**開発 [#bc235d98]
***編集 [#k4c56650]
nano README.md
***確認 [#teb2586c]
-変更のあったファイルを確認
git status
-それぞれの差分を確認
git diff
***追加 [#d48dd1fc]
ステージングに追加
-ファイル指定
git add README.md
-すべてのファイル
git add .
-間違った場合(作業ディレクトリに何の変更も加えることなく...
git reset
※ 基本的に1ファイル1ファイル指定したほうが良さそう。
***commit [#j950f480]
git commit -m "updated."
***pull [#n9f24272]
git pullコマンドはgit fetchコマンドとgit mergeコマンドを...
git pull origin <branch>
***push [#yec449a2]
pullしてpushすればコンフリクトはない。
git push origin <branch>
※ 任意の認証が必要になる。
*repository [#bcd73d11]
**clone [#md913091]
git clone は既存の git repositoryのclone (コピー) を作成...
-Git clone | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!clone
--既存の Git repositoryのコピーを作成する
--コピー元repositoryをポイントする origin という名称のrem...
--svn checkout と異なり、作業コピーがそれ自身で
---完全な git repositoryを構成する。
---履歴を持ってファイルを管理する。
-command
--local or remoteのrepositoryをcloneする。
git clone <repo>
--クローン先のdirectoryを指定してcloneする。
git clone <repo> <directory>
**repository間 [#p50d4a25]
***git remote [#pd21aa82]
-Git remote | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--他のrepositoryとの接続の作成、内容確認、削除を行う
--非短縮 URL への参照として使用可能な短縮名称として機能
***git fetch [#u260b8a6]
remote repositoryからfetchする。
-Git fetch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--remote repositoryからlocal repositoryにbranchをインポー...
--local branchとしてではなく、remote branchとして保存され...
--pullと異なりlocal repositoryにmergeする前に変更内容を確...
-commit
--remoteのすべてのbranchをfetchする。
git fetch <remote>
--remoteの特定のbranchをfetchする。
git fetch <remote> <branch>
***git pull [#r6fe7f69]
remote repositoryからpull(fetch & merge)する。
-Git pull | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--git fetch commandとそれに続く git merge commandをひとつ...
-command
--現在のbranchにremote branchをfetchして即時merge
git pull <remote>
--remote branchを現在のbranchにmergeする際に git [[rebase...
git pull --rebase <remote>
***git push [#ne215224]
remote repositoryへpushする。
-Git push | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/remote-reposito...
--local repositoryからremote repositoryにbranchをエクスポ...
---localな変更の中央repositoryへの公開
---remote repository内で git merge master commandを実行す...
---push先は --bare フラグを指定して作成したrepositoryに限...
-command
--指定したbranchを <remote> にpushする
git push <remote> <branch>
--すべてのlocal branchを指定したremote repositoryにpush
git push <remote> --all
--すべてのlocal tagをremote repositoryに送る
git push <remote> --tags
*branch [#df55a0b8]
**branch [#tf3a027e]
branchする
-Git branch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!b...
--branch(独立な開発ライン)の作成
--作業ディレクトリやステージングエリア、プロジェクト履歴...
-command
--現在のbranchから<new-branch>をbranchする~
「作成するだけで、切り替えはしない」 ので注意
git branch <new-branch>
**checkout [#u1308258]
branchをcheckoutする(切り替える)。
-Git checkout | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!c...
--branchを切り替える。
--HEADが移動することで、使用するbranchが変更される。
-command
--既存branch <existing-branch> に切り替える。
git checkout <existing-branch>
--新規branch <new-branch> を作成して即時checkout
git checkout -b <new-branch>
--既存branch <existing-branch>から新規branch <new-branch>...
git checkout -b <new-branch> <existing-branch>
**merge [#u18db080]
branchをmergeする。
-Git merge | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!m...
--branch(分岐した履歴)を現在のbranchへ統合する手段
-command
--指定したbranchを現在のbranchにmergeする
git merge <branch>
-- 「早送り」可能であっても、常にmerge commitを作成してme...
git merge --no-ff <branch>
-参考
--merge commitとFast-forward merge - Qiita~
http://qiita.com/shyamahira/items/59ff8aa1cf7b893aab60
**削除 [#v5c058a3]
branchを削除する。
-mergeされたbranchを削除する
git branch -d <experimental>
-mergeされたかどうかにかまわず削除する
git branch -D <experimental>
*開発 [#w9a915cb]
**ステージング [#y7ac6e3e]
***git add [#td795c21]
作業ディレクトリ内の変更をステージングエリアに追加
-Git add | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!add
--個々のファイルの変更内容を次回commitの対象とすることを ...
--git commit を実行するまでは変更がは実際に記録されない。
-command
--<file> に加えられたすべての変更をステージして次回のコミ...
git add <file>
--<directory> 内のすべての変更をステージして次回のコミッ...
git add <directory>
--インタラクティブなステージングセッションを開始する。
git add -p
***git clean [#maa79d68]
作業ディレクトリから追跡対象外のファイルを削除する
-Git clean | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--通常の rm コマンド同様 git clean コマンドも元に戻すこと...
-command
--git clean の「予行演習」を行うコマンドで削除されるファ...
git clean -n
--追跡対象外のファイルをカレントディレクトリから削除する。~
ただし、.gitignore. で指定したファイルは削除しない。
git clean -f
--追跡対象外のファイルを指定したパスから削除する。
git clean -f <path>
--追跡対象外のファイルとディレクトリをカレントディレクト...
git clean -df
--追跡対象外ファイルと通常無視されるファイルをカレントデ...
git clean -xf
***git reset [#y5c171a9]
ステージングエリアをリセットする(ワーキングツリーは変更...
-Git reset | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
-command
--作業ディレクトリに変更も加えずに、指定したファイルをス...
git reset <file>
--作業ディレクトリに何の変更も加えることなくステージエリ...
git reset
--ステージエリアと作業ディレクトリをresetして直前のcommit...
git reset --hard
**commitの操作 [#ufb99886]
<commit> = commit の"SHA-1 id"
***git commit [#sd4b5e04]
変更のcommit
-Git commit | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!com...
--ステージされたスナップショットを取り込んでlocal reposit...
--スナップショットは常にlocal repositoryにcommitされ、他...
-command
--ステージされたスナップショットをcommit。
git commit
--commit メッセージ付きでcommit。
git commit -m "<message>"
***git reset --hard [#y5c171a9]
履歴を完全に戻したい(かつ単独作業中)
-Git reset | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--commit済みのスナップショットを削除する目的でも使用され...
--git revert コマンドは変更を元に戻す「安全な」方法
--コレに対し、git reset コマンドは変更を元に戻す「危険な...
--復元方法が無いため、ローカルな変更を元に戻す場合に限る...
-command
--現在のbranchの先端を <commit> の位置に戻した上でステー...
これにより、変更規模が小さく整理されたスナップショットを...
git reset <commit>
--現在のbranchの先端を <commit> の位置に戻した上でステー...
commit前の変更に加えて <commit> の後に行われたすべてのcom...
git reset --hard <commit>
***git revert [#j96c5e46]
指定したコミットを「打ち消す」新しいコミットを作る(履歴...
-Git revert | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/undoing-changes...
--履歴を保全し、履歴の完全性とコラボレーションの信頼性を...
--commitがなかったものとするのではなくそのcommitによって...
-command
--特定のcommitのrevert
git revert <commit>
*確認 [#ed1a8ab6]
**branch [#l771f1ea]
***git branch [#t5e56642]
branchの確認
-Git branch | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-branches#!b...
--一覧表示
-command
--local branchの確認
git branch
--remote追跡branchを表示
git branch -r
--local branchとremote追跡branchの両方のbranchを表示
git branch -a
--名称の変更
git branch -m <branch>
**ステージング [#b46c38af]
***git status [#c4ba7161]
statusの確認
-Git status | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!sta...
--作業ディレクトリとステージングエリア(ステージされたス...
---ステージされた変更内容、
---ステージされていない変更内容
---Git による追跡の対象外となっているファイル
-command
--ステージされたファイル、されていないファイル、追跡対象...
git status
**commit [#dde136ae]
***git log [#aa03bcf5]
logの確認
-Git log | アトラシアン Git チュートリアル~
https://www.atlassian.com/ja/git/tutorial/git-basics#!log
--commit済みのスナップショットを表示するcommand
--commit済みの履歴 (commit履歴) のみが対象
---commit済み変更履歴の一覧表示
---それに対するフィルター処理
---特定の変更内容の検索
-command
--commit履歴全体をデフォルトの形式で表示
git log
--表示するcommit数を <limit> に制限する。
git log -n <limit>
--commit履歴を概観する(各々のcommitの内容を1行に圧縮して...
git log --oneline
--改変されたファイルおよびその中での追加行数と削除行数を...
git log --stat
--各々のcommitに対応するパッチ(commitの完全な差分情報)...
git log -p
*Rebase、Reset、Revert [#h1b9459f]
Rebase、Reset、Revert の違いと使い分け
**Rebase [#j203a3fa]
「履歴を綺麗にしたい」場合に使う(ローカルでのみ行うべき)
***概要 [#g5360a3f]
-ブランチの基点(親コミット)を変更することで、履歴を整理
-ブランチを最新の `main` ブランチに追従させる(の最新の状...
***動作イメージ [#z60b8dd4]
https://www.google.com/search?q=Rebase&udm=2
***注意点 [#g68d11bd]
-履歴を書き換えるため、リモートにプッシュしたコミットに対...
-既にリモートにpushしたコミットの履歴をrebaseで書き換えた...
--他の開発者のローカル履歴とリモートの履歴が不一致になり...
--リモートの意図しない履歴を書き換える可能性があり、また...
**Reset [#jde6ea7e]
「間違えてコミットした」場合に使う(ローカルでのみ行うべ...
***概要 [#le07b64f]
-指定したコミットに対して、現在のブランチを強制的に戻すコ...
-履歴を巻き戻すとともに、ワーキングツリーやインデックスの...
|モード|`git reset <commit>` の影響|h
|`--soft`|コミット履歴だけ戻し、インデックスやワーキング...
|`--mixed`(デフォルト)|コミットとインデックスは戻るが、...
|`--hard`|コミット、インデックス、ワーキングツリーすべて...
***注意点 [#b0a1d65c]
- `--hard` を使うと 変更が完全に消える ので、慎重に使うこ...
- リモートにプッシュ済みの履歴を変更すると他の開発者に影...
**Revert [#yc7d4458]
「リモートに影響を与えずに変更を取り消したい」(安全なの...
***概要 [#ef4308a4]
-履歴を維持しながら特定のコミットの変更を取り消すため、リ...
--指定したコミットを打ち消す「新しいコミット」を作成する...
--履歴を改変せずに変更を取り消すことができるため、安全な...
***注意点 [#m9c5025d]
--履歴が残るため、リセットのように「なかったこと」にはな...
--逆順にrevert(打ち消す「新しいコミット」)してもコンフ...
***比較表 [#c9211f1f]
|コマンド|目的|履歴の改変|影響範囲|h
|rebase|履歴を整理・ブランチを最新にする|する|ローカルの...
|reset|コミットを取り消す・巻き戻す |する|ローカルのみ(...
|revert|特定のコミットを打ち消す |しない|リモートでも安全|
ページ名: