-
ファイルの変更はそのままで直前のコミットを取り消す(Windows)
$git reset --soft "HEAD^"
-
gitignoreの変更を適用(管理しなくなったファイルの履歴も残さない(push前))
$git rm -r --cached .
$git add .
$git commit --amend --no-edit
-
ファイルを履歴ごと削除する
https://gist.github.com/ktx2207/3167fa69531bdd6b44f1
$git checkout testbranch
$git filter-branch --tree-filter "rm -f <ファイルパス>" HEAD -- .
$git filter-branch -f --tree-filter "rm -f <ファイルパス>" HEAD --all
$git reflog expire --expire=now --all
$git gc --aggressive --prune=now
$git push --force origin master
-
一時的にchangedを退避させる/戻す
git stash push
: 退避git stash pop
: 戻す
-
後からコミットに含める/修正する
- stageに何もない状態にする
git rebase -i HEAD~[さかのぼるコミット数]
- vimでコミット一覧が表示される
- iキーで入力モードにして、対象のコミットの
pick
をe
またはedit
に変更 ->ciwe
- Escキーで入力モードを終わって、
:wq
で保存 - ファイルを変更して
git add hoge
->git commit --amend
- push済みなら
git push -f
で上書きする
git commit --amend --no-edit
-
git push -forceのpull版
$ git fetch
$ git reset --hard origin/<branch_name>
-
submoduleの更新
$ git submodule init
既にしたことあったらなくてよい$ git submodule update --remote
-
submoduleの更新(任意のコミットへ)
- 上記submoduleの更新1と2をする
cd hoge
でsubmoduleのリポジトリへ移動git checkout <commitID>
- submodule内のファイルの更新
cd <submoduleのフォルダ>
git add .
git commit -m "<コミットメッセージ>"
git push origin HEAD:<ブランチ名>
- tagの削除
- ローカル:
git tag -d <tag名>
- リモート:
git push --delete origin <tag名>
- ローカル: