From a6be6a20ec36ad4770746ed4f0c7df1a88a896ca Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 18 Jul 2018 20:37:14 -0500 Subject: [PATCH] adding robert walker git-checkout.md to the mastering-github-students-project folder --- git-checkout-rw.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 git-checkout-rw.md diff --git a/git-checkout-rw.md b/git-checkout-rw.md new file mode 100644 index 0000000..f1c91e4 --- /dev/null +++ b/git-checkout-rw.md @@ -0,0 +1,56 @@ +# Git Checkout + +### Name +``` +- git checkout +``` + +### Synopsis +``` +git checkout [-q] [-f] [-m] [] +git checkout [-q] [-f] [-m] [[-b|-B|--orphan] ] [] +git checkout [-q] [-f] [-m] --detach [] +git checkout --patch [] [--] [...] +``` + +### Description +Updates files in the working tree to match the version in the index or the specified tree. The `git checkout` command operates upon three distinct entities: files, commits, and branches. If no paths are given, `git checkout` will also update `HEAD` to set the specified branch as the current branch. + +**git checkout \** +> 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 + +**git checkout -b|-B \ [\]** +> Specifying -b causes a new branch to be created as if `git branch` were called and then checked out +> If -B is given, is created if it doesn’t exist; otherwise, it is reset + +### Options +`-q` +`--quiet` +- Quiet, suppress feedback messages. + +`-f` +`--force` +- When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes +- When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored + +`-b ` +- Create a new branch named and start it at + +`-B ` +- Creates the branch and start it at . If it already exists, then reset it to . This is equivalent to running "git branch" with "-f" + +`-m` +`--merge` +- When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context + +`` +- Name for the new branch + +`` +- The name of a commit at which to start the new branch. Defaults to HEAD + +`` +- Tree to checkout from (when paths are given). If not specified, the index will be used. + +### Summary +This page focused on usage of the git checkout command when changing branches. In summation, git checkout, when used on branches, alters the target of the HEAD ref. It can be used to create branches, switch branches, and checkout remote branches. \ No newline at end of file