Correct suggested git commands for checkout 5.x #10713
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current instructions suggest
git checkout -b origin/5.x
, but this creates a new branch off of the current commit with the confusing name "origin/5.x" instead of creating a local branch with the default upstream of origin/5.x.Some better options include:
git checkout origin/5.x
- prints unnerving error message about detached head, but successfully checkout out 5.xgit checkout -b 5.x origin/5.x
- create a new branch off of origin/5.x, tracking origin/5.x - unfortunately confusing to typegit checkout 5.x
- for git 1.7.2.3 (2010) and higher (according to second hand source) does the same as command 2.git checkout --track origin/daves_branch
does the same for even older versions of git.I propose
git checkout -b 5.x origin/5.x
so as to make no assumptions about git version and to avoid the "detached head" warning that can be unnerving, and to prepare users to later pull to a tracking branch for updates. But we can rely on git version installed being less than 7 years old,git checkout 5.x
would be better.