赞
踩
git-checkout - 切换分支或回复工作目录文件
- git checkout [-q] [-f] [-m] [<branch>]
- git checkout [-q] [-f] [-m] --detach [<branch>]
- git checkout [-q] [-f] [-m] [--detach] <commit>
- git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
- git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>…
- git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]
- git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…]
更新工作目录中的文件,跟索引或者指定的引用相符。如果不给出pathspec,git checkout 会更新HEAD并设置指定分支为当前分支。
git checkout [<branch>]
为在<branch>上工作做准备
, 切换到分支并更新索引和工作目录中的文件,并将HEAD指向该分支。本地的修改会保留,这样它们可以被提交到<branch>。
If <branch>
is not found but there does exist a tracking branch in exactly one remote (call it <remote>
) with a matching name and --no-guess
is not specified, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
You could omit <branch>
, in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if exists, for the current branch.
git checkout -b|-B <new_branch> [<start point>]
Specifying -b
causes a new branch to be 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.
If -B
is given, <new_branch>
is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of
- $ git branch -f <branch> [<start point>]
- $ git checkout <branch>
that is to say, the branch is not reset/created unless "git checkout" is successful.
git checkout --detach [<branch>]
git checkout [--detach] <commit>
Prepare to work on top of <commit>
, by detaching HEAD
at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. Local modifications to the files in the working tree are kept, so that the resulting working tree will be the state recorded in the commit plus the local modifications.
When the <commit>
argument is a branch name, the --detach
option can be used to detach HEAD
at the tip of the branch (git checkout <branch>
would check out that branch without detaching HEAD
).
Omitting <branch>
detaches HEAD
at the tip of the current branch.
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>…
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]
Overwrite the contents of the files that match the pathspec. When the <tree-ish>
(most often a commit) is not given, overwrite working tree with the contents in the index. When the <tree-ish>
is given, overwrite both the index and the working tree with the contents at the <tree-ish>
.
The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the checkout operation will fail and nothing will be checked out. Using -f
will ignore these unmerged entries. The contents from a specific side of the merge can be checked out of the index by using --ours
or --theirs
. With -m
, changes made to the working tree file can be discarded to re-create the original conflicted merge result.
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…]
This is similar to the previous mode, but lets you use the interactive interface to show the "diff" output and choose which hunks to use in the result. See below for the description of --patch
option.
-q
--quiet
Quiet, suppress feedback messages.
--progress
--no-progress
Progress status is reported on the standard error stream by default when it is attached to a terminal, unless --quiet<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。