Skip to content

Commit

Permalink
Merge pull request #19985 from harsh8051/patch-2
Browse files Browse the repository at this point in the history
Update adding-locally-hosted-code-to-github.md to include procedures for newer and older versions of Git
  • Loading branch information
meowius authored Aug 26, 2022
2 parents 1fa7390 + 15679e0 commit 294aa18
Showing 1 changed file with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,21 @@ 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.
```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 %}
Expand Down Expand Up @@ -95,10 +105,19 @@ 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.
```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 .
Expand Down Expand Up @@ -132,10 +151,19 @@ 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.
```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 .
Expand Down

0 comments on commit 294aa18

Please sign in to comment.