2.1 Initializing a repository in an existing directory
- First, you need to open the command line prompt and navigate yourself to the directory you want to create the repo with.
- For example, it might look like this:
- Then, run the following command:
- The above command creates a new subdirectory named
.git that contains all of your necessary repository file.
- Note that at this point, nothing in your project is tracked yet.
- If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit.
git add -A
git commit -m "initial project version"
- Now, we need to connect it to GitHub (at this moment, your repository only exists locally):
- To do this, we have a choice between GitHub and UIUC CS GitHub Enterprise
- Create a new repository, then copy the URL (with .git at the end) provided after the repo is created.
- Go back to your command line prompt:
git remote add origin <your repo URL here>
git push origin master