unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* generating a git repo: main instead of master
@ 2022-11-13  8:03 Uwe Brauer
  2022-11-13  8:24 ` Eli Zaretskii
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Uwe Brauer @ 2022-11-13  8:03 UTC (permalink / raw)
  To: help-gnu-emacs


Hi

It seems that more and more public repositories expect that the principal git branch should be «main» instead of «master»


However, the following steps in emacs lead to a git repository, where the principal branch is master instead of main.

    1. Opening an empty file in an empty directory

    2. Write something and register the file

    3. Chose git

    4. Commit

Voila the result is 
,----
| * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> master)
|   Author: Uwe Brauer <oub@mat.ucm.es>
|   Date:   Sun Nov 13 09:01:42 2022 +0100
| 
|       First commit
`----

How can I change this behavior to have 
,----
| 
| * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> main)
|   Author: Uwe Brauer <oub@mat.ucm.es>
|   Date:   Sun Nov 13 09:01:42 2022 +0100
| 
|       First commit
`----

Thanks and regards

Uwe Brauer 

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
@ 2022-11-13  8:24 ` Eli Zaretskii
  2022-11-13  8:25   ` Eli Zaretskii
  2022-11-13  8:38   ` Uwe Brauer
  2022-11-13  8:26 ` Peter Hardy
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2022-11-13  8:24 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Uwe Brauer <oub@mat.ucm.es>
> Date: Sun, 13 Nov 2022 09:03:25 +0100
> 
> How can I change this behavior to have 
> ,----
> | 
> | * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> main)
> |   Author: Uwe Brauer <oub@mat.ucm.es>
> |   Date:   Sun Nov 13 09:01:42 2022 +0100
> | 
> |       First commit
> `----

If you want "master" to be the default, then from the shell prompt, do
the below once:

  $ git config --global init.defaultBranch main

Alternatively, after the initial commit do

  C-x v r main RET



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:24 ` Eli Zaretskii
@ 2022-11-13  8:25   ` Eli Zaretskii
  2022-11-13  8:38   ` Uwe Brauer
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2022-11-13  8:25 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sun, 13 Nov 2022 10:24:15 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> If you want "master" to be the default
              ^^^^^^^^
Sorry, this was supposed to be "main".



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
  2022-11-13  8:24 ` Eli Zaretskii
@ 2022-11-13  8:26 ` Peter Hardy
  2022-11-13  8:32 ` Teemu Likonen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Peter Hardy @ 2022-11-13  8:26 UTC (permalink / raw)
  To: help-gnu-emacs



On Sun, 13 Nov 2022, at 7:03 PM, Uwe Brauer wrote:
> How can I change this behavior to have 
> ,----
> | 
> | * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> main)

By configuring git to name the default branch `main`:

; git config --global init.defaultBranch main

man git-config has more details

-- 
Peter



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
  2022-11-13  8:24 ` Eli Zaretskii
  2022-11-13  8:26 ` Peter Hardy
@ 2022-11-13  8:32 ` Teemu Likonen
  2022-11-13  8:33 ` tomas
  2022-11-13  9:31 ` Jean Louis
  4 siblings, 0 replies; 12+ messages in thread
From: Teemu Likonen @ 2022-11-13  8:32 UTC (permalink / raw)
  To: Uwe Brauer, help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

* 2022-11-13 09:03:25+0100, Uwe Brauer wrote:

> How can I change this behavior to have 

> | * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> main)

Change Git's setting for the default branch name:

    $ git config --global init.defaultBranch main

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 251 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
                   ` (2 preceding siblings ...)
  2022-11-13  8:32 ` Teemu Likonen
@ 2022-11-13  8:33 ` tomas
  2022-11-13  8:43   ` Uwe Brauer
  2022-11-13  9:31 ` Jean Louis
  4 siblings, 1 reply; 12+ messages in thread
From: tomas @ 2022-11-13  8:33 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

On Sun, Nov 13, 2022 at 09:03:25AM +0100, Uwe Brauer wrote:
> 
> Hi
> 
> It seems that more and more public repositories expect that the principal git branch should be «main» instead of «master»
> 
> 
> However, the following steps in emacs lead to a git repository, where the principal branch is master instead of main.

You can change the master branch name to main with

  git branch -m master main

(think "move"). It is polite to coordinate with other people who
might have cloned your repo :)

To change the default at git init

  git config --global init.defaultBranch main

(git >= 2.28)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:24 ` Eli Zaretskii
  2022-11-13  8:25   ` Eli Zaretskii
@ 2022-11-13  8:38   ` Uwe Brauer
  2022-11-13  9:27     ` tomas
  2022-11-13 14:50     ` Björn Bidar
  1 sibling, 2 replies; 12+ messages in thread
From: Uwe Brauer @ 2022-11-13  8:38 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]

>>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

>> From: Uwe Brauer <oub@mat.ucm.es>
>> Date: Sun, 13 Nov 2022 09:03:25 +0100
>> 
>> How can I change this behavior to have 
>> ,----
>> | 
>> | * commit 9b1b90c4bb29dbb50320b71cf182e6ad46ab3ac5 (HEAD -> main)
>> |   Author: Uwe Brauer <oub@mat.ucm.es>
>> |   Date:   Sun Nov 13 09:01:42 2022 +0100
>> | 
>> |       First commit
>> `----

> If you want "master" to be the default, then from the shell prompt, do
> the below once:

>   $ git config --global init.defaultBranch main

That is a bit too much, maybe since other public git servers still stick
to master (bitbucket I think)



> Alternatively, after the initial commit do

>   C-x v r main RET

Thanks!

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:33 ` tomas
@ 2022-11-13  8:43   ` Uwe Brauer
  2022-11-13  9:22     ` tomas
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Brauer @ 2022-11-13  8:43 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

>>>   <tomas@tuxteam.de> writes:

> On Sun, Nov 13, 2022 at 09:03:25AM +0100, Uwe Brauer wrote:
>> 
>> Hi
>> 
>> It seems that more and more public repositories expect that the
>> principal git branch should be «main» instead of «master»
>> 
>> 
>> However, the following steps in emacs lead to a git repository, where
>> the principal branch is master instead of main.

> You can change the master branch name to main with

>   git branch -m master main

> (think "move"). It is polite to coordinate with other people who
> might have cloned your repo :)

Yeah, I find this all a bit messy to be honest. I'd prefer there would
be a common standard [1]

> To change the default at git init

>   git config --global init.defaultBranch main

> (git >= 2.28)

Oh I am still using 2.7.2 oh and also the command does not return error
it also does not work... time to upgrade!?

Uwe 
> Cheers


Footnotes:
[1] (no flamewar, but mercurial called its principal branch default
     right from the beginning, although I did not like the name, I do
     appreciate it now)

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:43   ` Uwe Brauer
@ 2022-11-13  9:22     ` tomas
  0 siblings, 0 replies; 12+ messages in thread
From: tomas @ 2022-11-13  9:22 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

On Sun, Nov 13, 2022 at 09:43:23AM +0100, Uwe Brauer wrote:
> >>>   <tomas@tuxteam.de> writes:

[...]

> > (think "move"). It is polite to coordinate with other people who
> > might have cloned your repo :)
> 
> Yeah, I find this all a bit messy to be honest. I'd prefer there would
> be a common standard [1]

Who does get everything right from the beginning?

> > To change the default at git init
> 
> >   git config --global init.defaultBranch main
> 
> > (git >= 2.28)
> 
> Oh I am still using 2.7.2 oh and also the command does not return error

This is expected. Git is somewhat extensible, so there's no central
wisdom about what settings make sense. The command just puts the
key/value into your personal git store. To wit:

  tomas@trotzki:~$ git config --global motor.proton.thrusters on

(no errors). Then:

  tomas@trotzki:~$ cat ~/.gitconfig 
  [...]
  [motor "proton"]
          thrusters = on

See? There it is, waiting for (some sub-part) of git to pick it
up when needed.

> it also does not work... time to upgrade!?

Don't be shy. The upside of the above scheme is that your change
will take effect once you upgrade :)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:38   ` Uwe Brauer
@ 2022-11-13  9:27     ` tomas
  2022-11-13 14:50     ` Björn Bidar
  1 sibling, 0 replies; 12+ messages in thread
From: tomas @ 2022-11-13  9:27 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 753 bytes --]

On Sun, Nov 13, 2022 at 09:38:16AM +0100, Uwe Brauer wrote:
> >>> "EZ" == Eli Zaretskii <eliz@gnu.org> writes:

[...]

> > If you want "master" to be the default, then from the shell prompt, do
> > the below once:
> 
> >   $ git config --global init.defaultBranch main
> 
> That is a bit too much, maybe since other public git servers still stick
> to master (bitbucket I think)

That shouldn't be an issue. This only sets the "default" branch when you
create a repo from scratch.

Choosing another default than "master" might confuse some people using
a very old git version [1]. But that's nothing unsurmountable.

Cheers

[1] https://stackoverflow.com/questions/18726037/what-determines-default-branch-after-git-clone

-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
                   ` (3 preceding siblings ...)
  2022-11-13  8:33 ` tomas
@ 2022-11-13  9:31 ` Jean Louis
  4 siblings, 0 replies; 12+ messages in thread
From: Jean Louis @ 2022-11-13  9:31 UTC (permalink / raw)
  To: help-gnu-emacs

* Uwe Brauer <oub@mat.ucm.es> [2022-11-13 11:05]:
> It seems that more and more public repositories expect that the
> principal git branch should be «main» instead of «master»

master has many definitions:

* Overview of noun master

The noun master has 10 senses (first 6 from tagged texts)
1. (8) maestro, master -- (an artist of consummate skill; "a master of the violin"; "one of the old masters")
2. (5) overlord, master, lord -- (a person who has general authority over others)
3. (1) victor, master, superior -- (a combatant who is able to defeat rivals)
4. (1) master -- (directs the work of others)
5. (1) headmaster, schoolmaster, master -- (presiding officer of a school)
6. (1) master, master copy, original -- (an original creation (i.e., an audio recording) from which copies can be made)
7. master, captain, sea captain, skipper -- (an officer who is licensed to command a merchant ship)
8. master -- (someone who holds a master's degree from academic institution)
9. master, professional -- (an authority qualified to teach apprentices)
10. passkey, passe-partout, master key, master -- (key that secures entrance everywhere)

So when we use "master" in git repositories, the definition number
6. applies, as in "master copy".

For everybody's attention, the definition "master" in git does not
apply to any living person who has general authority over others.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: generating a git repo: main instead of master
  2022-11-13  8:38   ` Uwe Brauer
  2022-11-13  9:27     ` tomas
@ 2022-11-13 14:50     ` Björn Bidar
  1 sibling, 0 replies; 12+ messages in thread
From: Björn Bidar @ 2022-11-13 14:50 UTC (permalink / raw)
  To: help-gnu-emacs

Uwe Brauer <oub@mat.ucm.es> writes:

>>   $ git config --global init.defaultBranch main
>
> That is a bit too much, maybe since other public git servers still stick
> to master (bitbucket I think)

They usually pick what is the first branch pushed, e.g. on my Gitea I
pushed the borg branch for emacs.d first and than it did thought I use
borg as master branch.

You can change the default branch in the setting of the relevant forge.
You can do this either for your own account, for your organization or
instance (if you run your own).

For example for Gitea the global option to set the default branch is this one:
https://docs.gitea.io/en-us/config-cheat-sheet/#repository-repository

Br,

Björn



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-11-13 14:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-13  8:03 generating a git repo: main instead of master Uwe Brauer
2022-11-13  8:24 ` Eli Zaretskii
2022-11-13  8:25   ` Eli Zaretskii
2022-11-13  8:38   ` Uwe Brauer
2022-11-13  9:27     ` tomas
2022-11-13 14:50     ` Björn Bidar
2022-11-13  8:26 ` Peter Hardy
2022-11-13  8:32 ` Teemu Likonen
2022-11-13  8:33 ` tomas
2022-11-13  8:43   ` Uwe Brauer
2022-11-13  9:22     ` tomas
2022-11-13  9:31 ` Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).