Confirmed users
1,643
edits
| Line 367: | Line 367: | ||
usage: git checkout [options] <branch> | usage: git checkout [options] <branch> | ||
or: git checkout [options] [<branch>] -- <file>... | or: git checkout [options] [<branch>] -- <file>... | ||
<span style="color:red">or: git checkout [options] [<commit>]</span> | |||
No wonder, there are also two forms in git-checkout: checkout HEAD to a '''branch''' or checkout '''files''' from a '''branch'''. Let's talk about the first form: checkout | No wonder, there are also two public forms in git-checkout: checkout HEAD to a '''branch''' or checkout '''files''' from a '''branch'''. I also appended a hidden usage, in red text color, after public forms. Let's talk about the first form: "git checkout [options] <branch>" | ||
# <span style="color:red">(Different with git-reset)</span> Change the referee(branch) of HEAD. | # <span style="color:red">(Different with git-reset)</span> Change the referee(branch ref) of HEAD. | ||
# <span style="color:red">(Different with git-reset)</span> There is no hardness-choice in git-checkout | # <span style="color:red">(Different with git-reset)</span> There is no hardness-choice in git-checkout. | ||
# <span style="color:red">(__"Similar"__ to git-reset-hard)</span> | # <span style="color:red">(__"Similar"__ to git-reset-hard)</span> git creates the index according to the root tree of the new assigned commit, and updates working directory. Almost the same with git-reset-hard, huh? Yes, but only if you checkout from a clean working directory: | ||
#*First, git-reset-hard never abort, while git-checkout will. | #*First, git-reset-hard never abort, while git-checkout will. | ||
#*Second, git-reset-hard compares the working directory and new tree, replace all modified tracked files in working directory by content in new tree; if your change in working directory does not cause any conflicts in checkout process, git will not erase the change. If the change indeed causes conflicts, then checkout aborting. Please see the next section for more details | #*Second, git-reset-hard compares the working directory and new tree, replace all modified tracked files in working directory by content in new tree; if your change in working directory does not cause any conflicts in checkout process, git will not erase the change. If the change indeed causes conflicts, then checkout aborting. Please see the next section for more details | ||