linux:git

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
次のリビジョン両方とも次のリビジョン
linux:git [2019/08/19 07:25] ともやんlinux:git [2020/03/07 16:58] – [参考文献] ともやん
行 5: 行 5:
 $ git pull $ git pull
 Already up to date. Already up to date.
 +</code>
 +
 +==== ローカルのファイルやディレクトリへの変更を破棄する ====
 +<code>
 +$ git checkout --force
 </code> </code>
  
行 14: 行 19:
  * branch              master     -> FETCH_HEAD  * branch              master     -> FETCH_HEAD
 </code> </code>
 +
 ローカルの master を、リモート追跡の master にリセットする。\\ ローカルの master を、リモート追跡の master にリセットする。\\
 <code> <code>
 $ git reset --hard origin/master $ git reset --hard origin/master
 +</code>
 +
 +**Untracked files** を(-d ディレクトリを含めて)削除する。\\
 +<code>
 +$ git clean -df
 +</code>
 +
 +**submodule** の **new commits, modified content** をリセットする。\\
 +<code>
 +$ git submodule foreach --recursive git reset --hard
 +</code>
 +
 +ローカルの状態を確認する。\\
 +<code>
 +$ git status
 +On branch master
 +Your branch is up to date with 'origin/master'.
 +
 +nothing to commit, working tree clean
 +</code>
 +
 +===== タグ/ブランチの使い方 =====
 +
 +==== タグ ====
 +リモートのタグを取得\\
 +<code>
 +$ git pull --tags
 +Already up to date.
 +</code>
 +
 +タグの一覧表示\\
 +<code>
 +$ git tag
 +wxPy-2.8.0.1
 +wxPy-2.8.0.2
 +...
 +wxPy-3.0.1.1
 +wxPy-3.0.2.0
 +</code>
 +
 +現在のブランチの直前のコミットに対してタグを付ける\\
 +<code>
 +$ git tag wxPy-3.0.2.0
 +</code>
 +
 +タグをチェックアウトする\\
 +<code>
 +$ 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
 +</code>
 +
 +タグからブランチを作成する\\
 +<code>
 +$ 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
 +</code>
 +
 +==== ブランチ ====
 +現在のブランチを表示\\
 +<code>
 +$ git branch
 +* master
 +</code>
 +
 +リモートブランチの一覧表示\\
 +<code>
 +$ 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
 +</code>
 +
 +タグ(wxPy-3.0.2.0)からブランチ(wxPyhton-3.0.2.0)を作成する\\
 +<code>
 +$ git checkout -b wxPyhton-3.0.2.0 wxPy-3.0.2.0
 </code> </code>
  
行 74: 行 184:
 ===== 参考文献 ===== ===== 参考文献 =====
 [[http://www-creators.com/archives/1097|git pull を強制し、リモートでローカルを上書きする方法 | WWWクリエイターズ]]\\ [[http://www-creators.com/archives/1097|git pull を強制し、リモートでローカルを上書きする方法 | WWWクリエイターズ]]\\
 +[[https://stackoverflow.com/questions/10906554/how-do-i-revert-my-changes-to-a-git-submodule|How do I revert my changes to a git submodule? - Stack Overflow]]\\
  
  • linux/git.txt
  • 最終更新: 2023/09/01 13:18
  • by ともやん