目次
文書の過去の版を表示しています。
Git - 分散型バージョン管理システム
リモートブランチの最新に合わせる
$ git pull Already up to date.
ローカルのファイルやディレクトリへの変更を破棄する
$ git checkout --force
強制的にリモートブランチの最新に合わせる
リモートの最新を取ってくる。
$ git fetch origin master From git://git.tomoyan.net/project_name * branch master -> FETCH_HEAD
ローカルの master を、リモート追跡の master にリセットする。
$ git reset --hard origin/master
Untracked files を(-d ディレクトリを含めて)削除する。
$ git clean -df
submodule の new commits, modified content をリセットする。
$ git submodule foreach --recursive git reset --hard
ローカルの状態を確認する。
$ git status On branch master Your branch is up to date with 'origin/master'. 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/12896), done. Note: switching to 'wxPy-3.0.2.0'. You are in 'detached HEAD' state. You can look around, make experimental 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 <new-branch-name> 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 'wxPyhton-3.0.2.0' $ git branch master * wxPyhton-3.0.2.0
ブランチ
現在のブランチを表示
$ git branch * master
リモートブランチの一覧表示
$ git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/SOC2007_UNITTEST ... remotes/origin/wxPy-2.9.3.x remotes/origin/wxPyhton-2.9.2
タグ(wxPy-3.0.2.0)からブランチ(wxPyhton-3.0.2.0)を作成する
$ git checkout -b wxPyhton-3.0.2.0 wxPy-3.0.2.0
トラブルシューティング
編集もしていないのにステータスで確認すると modified: が出続ける
$ git status On branch master Your branch is up to date with 'origin/master'. Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: .eslintignore modified: .eslintrc modified: .github/PULL_REQUEST_TEMPLATE.md modified: tool/unicode.js modified: tool/update_deps.js modified: tool/wrap_keyword_regexp.js no changes added to commit (use "git add" and/or "git commit -a")
編集を破棄する為に以下を実行してもステータスで確認すると modified: が出続ける。
$ git checkout . $ git checkout -- * $ git reset --hard origin/master
差分を確認するとファイルパーミッションの変更まで検知している。
$ git diff .eslintignore diff --git a/.eslintignore b/.eslintignore old mode 100644 new mode 100755
解決策はファイルパーミッションの変更を無視する。
$ git config core.filemode false $ git config -l core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true remote.origin.url=git://github.com/ajaxorg/ace.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master $ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean