search
Search
Login
Unlock 100+ guides
menu
menu
web
search toc
close
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to

Creating a new repository

schedule Aug 12, 2023
Last updated
local_offer
Tags
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

To create a new repository run the git init command in the directory which contains the files that you would like to track.

NOTE

A git repository is a directory having a .git directory serving as a virtual storage of your project. This enables you to track versions of your code and come back to them when needed.

From scratch

To create a new repository in the project2021 directory:

cd ~/project2021/
git init

Running the above command will create a new .git subdirectory under project2021 (current working directory).

To create a new directory called project2022 in the current directory and create a new project:

git init project2022

The above is equivalent to running mkdir project2022 && cd project2022 && git init

WARNING

It is not good practice to create a new repository inside another (i.e. nesting repositories) unless absolutely necessary, as you then need specify which .git folder to store changes in each time you make an update. As you can imagine, this quickly becomes very complicated to maintain.

Cloning an existing repository

To clone an existing repository we can use the git clone command with the following syntax:

Local repository

git clone <filepath> <newprojectname>

where:

  • <filepath> stands for the filepath of the local repository you would like to clone.

  • <newprojectname> stands for the name to give the cloned project in your home directory

Remote repository

git clone <URL> <newprojectname>

where:

  • <URL> stands for the URL of the repository you would like to clone

  • <newprojectname> stands for the name to give the cloned project in your home directory

robocat
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!