git checkout的主要功能就是迁出一个分支的特定版本。默认是迁出分支的HEAD版本
示例:
这条命令把 当前目录所有修改的文件 从HEAD中签出并且把它恢复成未修改时的样子.
注意:在使用git checkout 时,如果其对应的文件被修改过,那么该修改会被覆盖掉。
git checkout -b|-B <new_branch> [<start point>]
git checkout [--detach] [<commit>]
This form switches branches by updating the index, working tree, and HEAD to reflect the specified branch or commit.
If -b is given, a new branch is created as if git-branch(1) were called and then checked out; in this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.
git和版本库有冲突时解决办法:
[b]先执行以下pull动作,然后在执行push动作[/b]
示例:
git checkout master //取出master版本的head。
git checkout tag_name //在当前分支上 取出 tag_name 的版本
git checkout master file_name //放弃当前对文件file_name的修改
git checkout commit_id file_name //取文件file_name的 在commit_id是的版本。commit_id为 git commit 时的sha值。
$ git checkout -- hello.rb
这条命令把hello.rb从HEAD中签出.
$ git checkout .
这条命令把 当前目录所有修改的文件 从HEAD中签出并且把它恢复成未修改时的样子.
注意:在使用git checkout 时,如果其对应的文件被修改过,那么该修改会被覆盖掉。
git checkout -b|-B <new_branch> [<start point>]
git checkout [--detach] [<commit>]
This form switches branches by updating the index, working tree, and HEAD to reflect the specified branch or commit.
If -b is given, a new branch is created as if git-branch(1) were called and then checked out; in this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.
git和版本库有冲突时解决办法:
[b]先执行以下pull动作,然后在执行push动作[/b]