Git

您所在的位置:网站首页 checkoutout Git

Git

2024-07-12 02:11| 来源: 网络整理| 查看: 265

git checkout []

To prepare for working on , switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the .

If is not found but there does exist a tracking branch in exactly one remote (call it ) with a matching name and --no-guess is not specified, treat as equivalent to

$ git checkout -b --track /

You could omit , 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 it exists, for the current branch.

git checkout -b|-B []

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, is created if it doesn’t exist; otherwise, it is reset. This is the transactional equivalent of

$ git branch -f [] $ git checkout

that is to say, the branch is not reset/created unless "git checkout" is successful (e.g., when the branch is in use in another worktree, not just the current branch stays the same, but the branch is not reset to the start-point, either).

git checkout --detach [] git checkout [--detach]

Prepare to work on top of , 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 argument is a branch name, the --detach option can be used to detach HEAD at the tip of the branch (git checkout would check out that branch without detaching HEAD).

Omitting detaches HEAD at the tip of the current branch.

git checkout [-f|--ours|--theirs|-m|--conflict=] [] [--] …​ git checkout [-f|--ours|--theirs|-m|--conflict=] [] --pathspec-from-file= [--pathspec-file-nul]

Overwrite the contents of the files that match the pathspec. When the (most often a commit) is not given, overwrite working tree with the contents in the index. When the is given, overwrite both the index and the working tree with the contents at the .

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) [] [--] […​]

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.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3