Suggest to use `git checkout -B` in "Check out branch" instructions
What does this MR do and why?
Running git checkout -b contributor/fork-branch' FETCH_HEAD
(note the
lowercase -b
) twice fails with:
fatal: A branch named 'contributor/fork-branch' already exists.
Using git checkout -B
always works and just resets the branch if it
already exists:
git checkout -B contributor/fork-branch
Reset branch 'contributor/forr-branch'
According to man git-checkout
:
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.
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
- Go to a Community contribution MR like !95107 (merged)
- Click on Code > Check out branch (top right corner)
- Click on Copy commands next to Step 1
- Paste these commands in your console
- Paste these commands in your console again
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen