Add repository creation snippets
This commit is contained in:
23
snippets/clone-repo.md
Normal file
23
snippets/clone-repo.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
title: Clone a repository
|
||||||
|
tags: repository,remote,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Clones an existing repository, creating a local copy of it.
|
||||||
|
|
||||||
|
- Use `git clone <url>` to clone an existing repository from `<url>` to a local directory. The directory's name will be based on the name of the cloned repository.
|
||||||
|
- Alternatively, use `git clone <url> [<directory>]` to clone the repository into the specified local `<directory>`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone <url> [<directory>]
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/30-seconds/30-seconds-of-code.git
|
||||||
|
# Clones the repository in a new directory named '30-seconds-of-code'
|
||||||
|
cd 30-seconds-of-code
|
||||||
|
|
||||||
|
git clone https://github.com/30-seconds/30-seconds-of-code.git my-project
|
||||||
|
# Clones the repository in a new directory named 'my-project'
|
||||||
|
cd my-project
|
||||||
|
```
|
||||||
23
snippets/create-repo.md
Normal file
23
snippets/create-repo.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
title: Create a new repository
|
||||||
|
tags: repository,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Initializes a new git repository, setting up all the configuration files needed by git.
|
||||||
|
|
||||||
|
- Use `git init` to initialize an empty repository in the current directory.
|
||||||
|
- Alternatively, use `git init [<directory>]` to initialize the repository in the specified `<directory>`.
|
||||||
|
- Note: Running `git init` in an existing repository is safe.
|
||||||
|
- Note: You only need to run `git init` once per repository.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git init [<directory>]
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ~/my_project
|
||||||
|
git init # Initializes a repo in ~/my_project
|
||||||
|
|
||||||
|
cd ~
|
||||||
|
git init my_project # Initializes a repo in ~/my_project
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user