差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
linux:git [2019/09/13 09:22] – [強制的にリモートブランチの最新に合わせる] ともやん | linux:git [2020/03/07 17:00] – [強制的にリモートブランチの最新に合わせる] ともやん | ||
---|---|---|---|
行 5: | 行 5: | ||
$ git pull | $ git pull | ||
Already up to date. | Already up to date. | ||
+ | </ | ||
+ | |||
+ | ==== ローカルのファイルやディレクトリへの変更を破棄する ==== | ||
+ | < | ||
+ | $ git checkout --force | ||
</ | </ | ||
行 14: | 行 19: | ||
* branch | * branch | ||
</ | </ | ||
+ | |||
ローカルの master を、リモート追跡の master にリセットする。\\ | ローカルの master を、リモート追跡の master にリセットする。\\ | ||
< | < | ||
$ git reset --hard origin/ | $ git reset --hard origin/ | ||
</ | </ | ||
+ | |||
+ | **Untracked files** を(-d ディレクトリを含めて)削除する。\\ | ||
+ | < | ||
+ | $ git clean -df | ||
+ | </ | ||
+ | |||
+ | **submodule** の **new commits, modified content** をリセットする。\\ | ||
+ | < | ||
+ | $ git submodule foreach --recursive git reset --hard | ||
+ | </ | ||
+ | |||
+ | **submodule** の **new commits** をリセットする。\\ | ||
+ | < | ||
+ | $ git submodule update --init | ||
+ | </ | ||
+ | |||
ローカルの状態を確認する。\\ | ローカルの状態を確認する。\\ | ||
< | < | ||
行 26: | 行 48: | ||
nothing to commit, working tree clean | nothing to commit, working tree clean | ||
</ | </ | ||
+ | |||
+ | ===== タグ/ | ||
+ | |||
+ | ==== タグ ==== | ||
+ | リモートのタグを取得\\ | ||
+ | < | ||
+ | $ git pull --tags | ||
+ | Already up to date. | ||
+ | </ | ||
+ | |||
+ | タグの一覧表示\\ | ||
+ | < | ||
+ | $ git tag | ||
+ | wxPy-2.8.0.1 | ||
+ | wxPy-2.8.0.2 | ||
+ | ... | ||
+ | wxPy-3.0.1.1 | ||
+ | wxPy-3.0.2.0 | ||
+ | </ | ||
+ | |||
+ | 現在のブランチの直前のコミットに対してタグを付ける\\ | ||
+ | < | ||
+ | $ git tag wxPy-3.0.2.0 | ||
+ | </ | ||
+ | |||
+ | タグをチェックアウトする\\ | ||
+ | < | ||
+ | $ git checkout wxPy-3.0.2.0 | ||
+ | Updating files: 100% (12896/ | ||
+ | Note: switching to ' | ||
+ | |||
+ | You are in ' | ||
+ | changes and commit them, and you can discard any commits you make in this | ||
+ | state without impacting any branches by switching back to a branch. | ||
+ | |||
+ | If you want to create a new branch to retain commits you create, you may | ||
+ | do so (now or later) by using -c with the switch command. Example: | ||
+ | |||
+ | git switch -c < | ||
+ | |||
+ | Or undo this operation with: | ||
+ | |||
+ | git switch - | ||
+ | |||
+ | Turn off this advice by setting config variable advice.detachedHead to false | ||
+ | |||
+ | HEAD is now at 67db99581e set revisions for externals | ||
+ | |||
+ | $ git branch | ||
+ | * (HEAD detached at wxPy-3.0.2.0) | ||
+ | master | ||
+ | </ | ||
+ | |||
+ | タグからブランチを作成する\\ | ||
+ | < | ||
+ | $ git checkout -b wxPyhton-3.0.2.0 | ||
+ | Switched to a new branch ' | ||
+ | |||
+ | $ git branch | ||
+ | master | ||
+ | * wxPyhton-3.0.2.0 | ||
+ | </ | ||
+ | |||
+ | ==== ブランチ ==== | ||
+ | 現在のブランチを表示\\ | ||
+ | < | ||
+ | $ git branch | ||
+ | * master | ||
+ | </ | ||
+ | |||
+ | リモートブランチの一覧表示\\ | ||
+ | < | ||
+ | $ git branch -a | ||
+ | * master | ||
+ | remotes/ | ||
+ | remotes/ | ||
+ | ... | ||
+ | remotes/ | ||
+ | remotes/ | ||
+ | </ | ||
+ | |||
+ | タグ(wxPy-3.0.2.0)からブランチ(wxPyhton-3.0.2.0)を作成する\\ | ||
+ | < | ||
+ | $ git checkout -b wxPyhton-3.0.2.0 wxPy-3.0.2.0 | ||
+ | </ | ||
+ | |||
===== トラブルシューティング ===== | ===== トラブルシューティング ===== | ||
行 81: | 行 189: | ||
===== 参考文献 ===== | ===== 参考文献 ===== | ||
[[http:// | [[http:// | ||
+ | [[https:// | ||