こんにちは!
まったりのんびり、@vVv_kenshi_vVvです!
Gitの状態を綺麗にする
プラグインアップデートしたけど取り消したい時、あれこれいじったけどやっぱり取り消したい時
Bash
name@pc eccube % git status
On branch develop
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .htaccess
modified: app/Plugin/VeriTrans4G/Controller/PaymentController.php
modified: app/Plugin/VeriTrans4G/EventListener/Vt4gEvent.php
modified: composer.json
modified: composer.lock
modified: vendor/composer/autoload_classmap.php
modified: vendor/composer/autoload_static.php
modified: vendor/composer/installed.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
app/Plugin/VeriTrans4G/Common/
app/Plugin/VeriTrans4G/Resource/tgMdkPHP/tgMdk/Lib/tgMdkDto/RakutenReAuthorizeRequestDto.php
app/Plugin/VeriTrans4G/Resource/tgMdkPHP/tgMdk/Lib/tgMdkDto/RakutenReAuthorizeResponseDto.php
no changes added to commit (use "git add" and/or "git commit -a")
name@pc eccube % ・全ての変更の破棄:Changes not staged for commit
Bash
git checkout .未追跡ファイル、ディレクトリの削除:Untracked files
Bash
git clean -dfコマンド実行後
Bash
name@pc eccube % git status
On branch develop
nothing to commit, working tree clean
name@pc eccube % ローカル環境のみ追跡除外したい
環境により設定が違う場合に、Gitの追跡から除外したい場合に使う
Bash
git update-index --skip-worktree .htaccessGitコマンド一覧
ついつい調べてしまう、忘れっぽいあなた(私)の為に捧げるw
記事です!
リセット系
取り消しやコミット履歴を綺麗にする際に、使用するコマンドを紹介
reset
・直前のコミットの取り消し
Bash
git reset --herd HEAD^・直前のリセットの取り消し
Bash
git reset --hard ORIG_HEAD・addファイルを破棄する(最後にコミットした状態へ戻す)
Bash
git checkout HEAD -- [ファイル名]未追跡ファイルの削除
Bash
git clean -fcheckout
・変更の破棄(ファイルの削除ではない)
Bash
git checkout HEAD ファイル名
git checkout HEAD app/Customize/TestController.php・指定ディレクトリは以下の破棄
Bash
git checkout HEAD ディレクトリ名
git checkout HEAD app/Plugin/Api/・全ての変更の破棄
Bash
git checkout .ログ関連
表示を見やすくするのに使用するコマンド(オプション)
log
・GUI( SourceTree など)までは、見やすくはなりませんが、気持ち良くなります。
Bash
git log --oneline --graph --decorate・マージ履歴
Bash
git log --oneline --mergedCheckout
developブランチへ移動
Bash
git checkout develop指定の作業ブランチへ移動
Bash
git checkout feature/XXX作業ブランチを作成して移動
Bash
git checkout -b feature/XXXCommit
直前のコミットメッセージ変更
Bash
git commit --amendPush
指定ブランチをリモートブランチへプッシュ
Bash
git push origin feature/XXX安全な強制プッシュ
Bash
git push --force-with-lease origin feature/XXXRebase
直前の2コミットをまとめる
Bash
git rebase -i HEAD~2Rebase取消
Bash
git rebase --abort再Rebase
Bash
git rebase --continuedevelopブランチを現在ブランチへRebaseする
Bash
git rebase developStash
現在状況を退避する
Bash
git stash直近のStashを適用する
Bash
git stash applyBranch関連
・developブランチにマージ済みローカルブランチの削除
Bash
git branch --merged develop | grep -vE '^\*|master$|develop$' | xargs git branch -d


コメント