Message ID | 20240407212109.35131-1-benji@FisherFam.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | MyFirstContribution: use switch for changing branches | expand |
Benji Fisher <benji@FisherFam.org> writes:
> Use "git switch" instead of "git checkout" for changing branches.
... because?
In the proposed log message, make sure you are telling the readers
WHY the change was needed and desirable.
The usual way to compose a log message for this project is to
- Give an observation on how the current system work in the present
tense (so no need to say "Currently X is Y", just "X is Y"), and
discuss what you perceive as a problem in it.
- Propose a solution (optional---often, problem description
trivially leads to an obvious solution in reader's minds).
- Give commands to the codebase to "become like so".
in this order.
For this particular patch, I do not see a compelling reason why we
should make these changes. It is not like MyFirst* documents
consistently uses "git switch" (and "git restore") in other places
and these three are the exceptions (in which case that would be a
very good justification you would describe in the "observation"
paragraph of your proposed log message). We are not deprecating
"git checkout", either.
Thanks.
On Mon, Apr 8, 2024 at 1:42 PM Junio C Hamano <gitster@pobox.com> wrote: > > For this particular patch, I do not see a compelling reason why we > should make these changes. It is not like MyFirst* documents > consistently uses "git switch" (and "git restore") in other places > and these three are the exceptions (in which case that would be a > very good justification you would describe in the "observation" > paragraph of your proposed log message). We are not deprecating > "git checkout", either. I was under the impression that the new "git switch" and "git restore" commands were recommended in most cases instead of "git checkout". If not, then I withdraw my suggestion. I apologize for making noise on this list. Thanks for considering my patch. Thanks even more for maintaining git.
> I was under the impression that the new "git switch" and "git restore" > commands were recommended in most cases instead of "git checkout". For new users, yes. For someone who's looking to contribute to core git - probably not.
Benji Fisher <benji@fisherfam.org> writes: > I was under the impression that the new "git switch" and "git restore" > commands were recommended in most cases instead of "git checkout". These two were added so that eventually we have something we can recommend to new users, but as a pair of experimental commands, we reserve the rights to update their UI in backward incompatible ways (meaning: those who use them may need to retrain their fingers and update their scripts if they used them---not that using these Porcelain commands in scripts is a good idea to begin with). So your justification could be We want to evantually be able to recommend restore/switch to new users, and want to take advantage of every opportunity to polish them. Because this document is not exactly for totally new users, and the readers are expected to be knowledgeable enough and highly motivated in improving git, let's have them use these experimental commands and report newbie-issues they found using them, so that we can gain more experience and chances to polish the command and eventually make them recommendable to new users. Note that the "WHY?" in my response was not "I see no reason to do this", but "You need to say why you think this is a good idea here in the proposed commit log message". Without your version of reasoning, my conclusion was "I do not see a point", but with a justification like this (there could be others---it is contributor's job to explain why a proposed change is a good idea, not mine), I can understand the reasoning why this change may be a good one. Thanks.
On Tue, Apr 9, 2024 at 9:11 AM Junio C Hamano <gitster@pobox.com> wrote: > > Benji Fisher <benji@fisherfam.org> writes: > > > I was under the impression that the new "git switch" and "git restore" > > commands were recommended in most cases instead of "git checkout". > > These two were added so that eventually we have something we can > recommend to new users, but as a pair of experimental commands, we > reserve the rights to update their UI in backward incompatible ways > (meaning: those who use them may need to retrain their fingers and > update their scripts if they used them---not that using these > Porcelain commands in scripts is a good idea to begin with). > > So your justification could be > > We want to evantually be able to recommend restore/switch to new > users, and want to take advantage of every opportunity to polish > them. > > Because this document is not exactly for totally new users, and > the readers are expected to be knowledgeable enough and highly > motivated in improving git, let's have them use these > experimental commands and report newbie-issues they found using > them, so that we can gain more experience and chances to polish > the command and eventually make them recommendable to new users. > > Note that the "WHY?" in my response was not "I see no reason to do > this", but "You need to say why you think this is a good idea here > in the proposed commit log message". Without your version of > reasoning, my conclusion was "I do not see a point", but with a > justification like this (there could be others---it is contributor's > job to explain why a proposed change is a good idea, not mine), I > can understand the reasoning why this change may be a good one. For what it's worth, when I wrote this doc I was new enough to hacking Git that I did not know about the new experimental commands ;) or else I would have used them. I am not opposed to pointing them out in this doc as part of general evangelism towards a nice UX improvement (and that could be good justification for the commit message, if you agree, Benji). - Emily
diff --git a/Documentation/MyFirstContribution.txt b/Documentation/MyFirstContribution.txt index f06563e981..66f38a7055 100644 --- a/Documentation/MyFirstContribution.txt +++ b/Documentation/MyFirstContribution.txt @@ -122,7 +122,7 @@ branch of the upstream project. Create the `psuh` branch you will use for development like so: ---- -$ git checkout -b psuh origin/master +$ git switch -c psuh origin/master ---- We'll make a number of commits here in order to demonstrate how to send a topic @@ -878,7 +878,7 @@ on `master`, so go ahead and update as shown below, or using your preferred workflow. ---- -$ git checkout master +$ git switch master $ git pull -r $ git rebase master psuh ---- @@ -1139,7 +1139,7 @@ We'll reuse our `psuh` topic branch for v2. Before we make any changes, we'll mark the tip of our v1 branch for easy reference: ---- -$ git checkout psuh +$ git switch psuh $ git branch psuh-v1 ----
Use "git switch" instead of "git checkout" for changing branches. Signed-off-by: Benji Fisher <benji@FisherFam.org> --- Documentation/MyFirstContribution.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)