From bdb80dac4810fe449906328dd5742b6b412044a3 Mon Sep 17 00:00:00 2001 From: harsh8051 <105968770+harsh8051@users.noreply.github.com> Date: Fri, 19 Aug 2022 17:30:42 +0530 Subject: [PATCH 1/3] Update adding-locally-hosted-code-to-github.md This change is made to display a warning to reader that ``` -b main ``` flag does not older version of git. --- .../adding-locally-hosted-code-to-github.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md index 97b049d2de..d195872459 100644 --- a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md +++ b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md @@ -59,6 +59,13 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Initialize the local directory as a Git repository. + + {% warning %} + + **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above + + {% endwarning %} + ```shell $ git init -b main ``` @@ -96,6 +103,13 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Initialize the local directory as a Git repository. + + {% warning %} + + **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above + + {% endwarning %} + ```shell $ git init -b main ``` @@ -133,6 +147,13 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Initialize the local directory as a Git repository. + + {% warning %} + + **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above + + {% endwarning %} + ```shell $ git init -b main ``` From ffb98cbee783a5778fc912f1f06f9b2010feabc7 Mon Sep 17 00:00:00 2001 From: Annelisa Stephan Date: Thu, 25 Aug 2022 16:17:40 -0700 Subject: [PATCH 2/3] Add info for Git versions below and above 2.28.0. Clarified how to do this step in Git 2.27.1 and earlier. --- .../adding-locally-hosted-code-to-github.md | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md index d195872459..dd15722e7b 100644 --- a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md +++ b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md @@ -58,17 +58,10 @@ If you have existing source code or repositories stored locally on your computer ![Create New Repository drop-down](/assets/images/help/repository/repo-create.png) {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. -4. Initialize the local directory as a Git repository. - - {% warning %} - - **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above - - {% endwarning %} - - ```shell +4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. + ``` shell $ git init -b main - ``` 5. Add the files in your new local repository. This stages them for the first commit. ```shell $ git add . @@ -102,14 +95,10 @@ If you have existing source code or repositories stored locally on your computer ![Create New Repository drop-down](/assets/images/help/repository/repo-create.png) {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. -4. Initialize the local directory as a Git repository. - - {% warning %} - - **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above - - {% endwarning %} - +4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. + ``` shell + $ git init -b main ```shell $ git init -b main ``` @@ -146,13 +135,10 @@ If you have existing source code or repositories stored locally on your computer ![Create New Repository drop-down](/assets/images/help/repository/repo-create.png) {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. -4. Initialize the local directory as a Git repository. - - {% warning %} - - **Warning:** `-b ` flag in following command does not work with git version below *2.28.0*. Use same or above - - {% endwarning %} +4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. + ``` shell + $ git init -b main ```shell $ git init -b main From 808d77e458183c99c8c6c428ff36f6d3c6d521e5 Mon Sep 17 00:00:00 2001 From: Annelisa Stephan Date: Thu, 25 Aug 2022 20:18:38 -0700 Subject: [PATCH 3/3] Fix shell formatting --- .../adding-locally-hosted-code-to-github.md | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md index dd15722e7b..30a25ec8ae 100644 --- a/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md +++ b/content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md @@ -59,10 +59,20 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. - ``` shell - $ git init -b main + + ``` shell + $ git init -b main + ``` + + If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`. + + ``` shell + $ git init && git branch -m main + ``` 5. Add the files in your new local repository. This stages them for the first commit. + ```shell $ git add . # Adds the files in the local repository and stages them for commit. {% data reusables.git.unstage-codeblock %} @@ -96,12 +106,18 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. - ``` shell - $ git init -b main - ```shell - $ git init -b main - ``` + + ``` shell + $ git init -b main + ``` + + If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`. + + ``` shell + $ git init && git branch -m main + ``` 5. Add the files in your new local repository. This stages them for the first commit. ```shell $ git add . @@ -136,13 +152,18 @@ If you have existing source code or repositories stored locally on your computer {% data reusables.command_line.open_the_multi_os_terminal %} 3. Change the current working directory to your local project. 4. Use the `init` command to initialize the local directory as a Git repository. By default, the initial branch is called `master`. - If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. - ``` shell - $ git init -b main - ```shell - $ git init -b main - ``` + If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using `-b`. + + ``` shell + $ git init -b main + ``` + + If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`. + + ``` shell + $ git init && git branch -m main + ``` 5. Add the files in your new local repository. This stages them for the first commit. ```shell $ git add .