最終更新:2016-02-16 (火) 14:31:33 (2985d)  

TortoiseGit/コマンド/Switch/Checkout

Switch To

  • Branch
  • Tag
  • Commit

Option

  • Create New Branch
  • Overwrite working tree changes (force)
  • Merge
  • Track
  • Override branch if exists

動作

  • git checkout
    • git checkoutに「-b」オプションを付けて実行すると、新たにブランチを作成してそのブランチに切り替える、という作業が一発で行える

リポジトリ

  • クローン直後の.git/config
    [core]
    	repositoryformatversion = 0
    	filemode = false
    	bare = false
    	logallrefupdates = true
    	symlinks = false
    	ignorecase = true
    	hideDotFiles = dotGitOnly
    [remote "origin"]
    	url = git://github.com/schacon/ticgit.git
    	fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    	remote = origin
    	merge = refs/heads/master

トラックする+ブランチ作成

  • $ git.exe checkout -b ticgit remotes/origin/ticgit --
    
    Branch ticgit set up to track remote branch ticgit from origin.
    Switched to a new branch 'ticgit'
    
    Success (219 ms @ 2016/02/16 14:22:53)
  • .git/configに下記を追加
    [branch "ticgit"]
    	remote = origin
    	merge = refs/heads/ticgit

トラックする+ブランチ作成しない

  • $ git.exe checkout remotes/origin/ticgit --
    
    Note: checking out 'remotes/origin/ticgit'.
    
    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 performing another checkout.
    
    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:
    
    git checkout -b <new-branch-name>
    
    HEAD is now at c6edfec... Merge commit 'pope/ticgit' into ticgit
    
    Success (188 ms @ 2016/02/16 14:23:17)
    

トラックしない+ブランチ作成

  • $ git.exe checkout --no-track -b ticgit remotes/origin/ticgit --
    
    Switched to a new branch 'ticgit'
    
    Success (187 ms @ 2016/02/16 14:24:46)