Merge pull request #19985 from harsh8051/patch-2
Update adding-locally-hosted-code-to-github.md to include procedures for newer and older versions of Git
This commit is contained in:
@@ -58,11 +58,21 @@ 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.
|
||||
```shell
|
||||
$ git init -b main
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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 %}
|
||||
@@ -95,10 +105,19 @@ 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.
|
||||
```shell
|
||||
$ git init -b main
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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 .
|
||||
@@ -132,10 +151,19 @@ 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.
|
||||
```shell
|
||||
$ git init -b main
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
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 .
|
||||
|
||||
Reference in New Issue
Block a user