差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
linux:git [2019/03/01 23:23] – ともやん | linux:git [2020/03/07 16:05] – [強制的にリモートブランチの最新に合わせる] ともやん | ||
---|---|---|---|
行 1: | 行 1: | ||
- | <ifauth !@loggedinusers>< | ||
- | < | ||
- | (adsbygoogle = window.adsbygoogle || []).push({ | ||
- | google_ad_client: | ||
- | enable_page_level_ads: | ||
- | }); | ||
- | </ | ||
====== Git - 分散型バージョン管理システム ====== | ====== Git - 分散型バージョン管理システム ====== | ||
行 12: | 行 5: | ||
$ git pull | $ git pull | ||
Already up to date. | Already up to date. | ||
+ | </ | ||
+ | |||
+ | ==== ローカルのファイルやディレクトリへの変更を破棄する ==== | ||
+ | < | ||
+ | $ git checkout --force | ||
</ | </ | ||
行 21: | 行 19: | ||
* branch | * branch | ||
</ | </ | ||
+ | |||
ローカルの master を、リモート追跡の master にリセットする。\\ | ローカルの master を、リモート追跡の master にリセットする。\\ | ||
< | < | ||
$ git reset --hard origin/ | $ git reset --hard origin/ | ||
+ | </ | ||
+ | |||
+ | **Untracked files** を(-d ディレクトリを含めて)削除する。\\ | ||
+ | < | ||
+ | $ git clean -df | ||
+ | </ | ||
+ | |||
+ | ローカルの状態を確認する。\\ | ||
+ | < | ||
+ | $ git status | ||
+ | On branch master | ||
+ | Your branch is up to date with ' | ||
+ | |||
+ | 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 | ||
</ | </ | ||