Skip to content

Commit 7e9ba93

Browse files
authored
Merge pull request #1780 from ekohl/avoid-git-branch-rename
Ignore the default branch name problem
2 parents 39b7faa + d6968a0 commit 7e9ba93

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

en/deploy/README.md

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@ $ git config --global user.email you@example.com
3131
```
3232
Initializing the git repository is something we need to do only once per project (and you won't have to re-enter the username and email ever again).
3333

34-
### Adjusting your branch name
35-
36-
If the version of Git that you are using is older than **2.28**, you will need to change the name of your branch to "main". To determine the version of Git, please enter the following command:
37-
38-
{% filename %}command-line{% endfilename %}
39-
```
40-
$ git --version
41-
git version 2.xx...
42-
```
43-
44-
Only if the second number of the version, shown as "xx" above, is less than 28, will you need to enter the following command to rename your branch. If it is 28 or higher, please continue to "Ignoring files". As in "Initializing", this is something we need to do only once per project, as well as only when your version of Git is less than 2.28:
45-
46-
{% filename %}command-line{% endfilename %}
47-
```
48-
$ git branch -M main
49-
```
50-
5134
### Ignoring files
5235

5336
Git will track changes to all the files and folders in this directory, but there are some files we want it to ignore. We do this by creating a file called `.gitignore` in the base directory. Open up your editor and create a new file with the following contents:
@@ -153,7 +136,7 @@ Type the following into your console (replace `<your-github-username>` with the
153136
{% filename %}command-line{% endfilename %}
154137
```
155138
$ git remote add origin https://github.com/<your-github-username>/my-first-blog.git
156-
$ git push -u origin main
139+
$ git push -u origin HEAD
157140
```
158141

159142
When you push to GitHub, you'll be asked for your GitHub username and password (either right there in the command-line window or in a pop-up window), and after entering credentials you should see something like this:

en/deploy/install_git.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ data-collapse=true ces-->
77

88
You can download Git from [git-scm.com](https://git-scm.com/). You can hit "next" on all steps except for two: in the step where it asks to choose your editor, you should pick Nano, and in the step entitled "Adjusting your PATH environment", choose "Use Git and optional Unix tools from the Windows Command Prompt" (the bottom option). Other than that, the defaults are fine. Checkout Windows-style, commit Unix-style line endings is good.
99

10-
During installation, if you are presented with the option of "Adjusting the name of the initial branch in new repositories", please choose to "Override the default" and use "main". This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject.
11-
1210
Do not forget to restart the command prompt or PowerShell after the installation finished successfully.
1311
<!--endsec-->
1412

@@ -17,8 +15,6 @@ data-collapse=true ces-->
1715

1816
Download Git from [git-scm.com](https://git-scm.com/) and follow the instructions.
1917

20-
During installation, if you are presented with the option of "Adjusting the name of the initial branch in new repositories", please choose to "Override the default" and use "main". This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject.
21-
2218
> **Note** If you are running OS X 10.6, 10.7, or 10.8, you will need to install the version of git from here: [Git installer for OS X Snow Leopard](https://sourceforge.net/projects/git-osx-installer/files/git-2.3.5-intel-universal-snow-leopard.dmg/download)
2319
2420
<!--endsec-->
@@ -31,15 +27,6 @@ data-collapse=true ces-->
3127
$ sudo apt install git
3228
```
3329

34-
### Adjusting your default branch name
35-
36-
This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject.
37-
38-
{% filename %}command-line{% endfilename %}
39-
```
40-
$ git config --global --add init.defaultBranch main
41-
```
42-
4330
<!--endsec-->
4431

4532
<!--sec data-title="Installing Git: Fedora" data-id="git_install_fedora"
@@ -50,15 +37,6 @@ data-collapse=true ces-->
5037
$ sudo dnf install git
5138
```
5239

53-
### Adjusting your default branch name
54-
55-
This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject.
56-
57-
{% filename %}command-line{% endfilename %}
58-
```
59-
$ git config --global --add init.defaultBranch main
60-
```
61-
6240
<!--endsec-->
6341

6442
<!--sec data-title="Installing Git: openSUSE" data-id="git_install_openSUSE"
@@ -69,13 +47,4 @@ data-collapse=true ces-->
6947
$ sudo zypper install git
7048
```
7149

72-
### Adjusting your default branch name
73-
74-
This will align your installation of Git with the broad direction of the global developer community, and the "main" branch will be used through the remainder of this tutorial. Please see https://sfconservancy.org/news/2020/jun/23/gitbranchname/ and https://github.com/github/renaming for further discussion of this subject.
75-
76-
{% filename %}command-line{% endfilename %}
77-
```
78-
$ git config --global --add init.defaultBranch main
79-
```
80-
8150
<!--endsec-->

0 commit comments

Comments
 (0)