How to link your Git Repository to your working folder
A git repository stores and tracks changes in a project on GitHub. You can setup a repository to manage your project by doing the following:
- Create a new folder for your project. You can do this through the terminal by using the mkdir project_name command. Then go to that folder in your terminal by using the cd command.
2. Now you can create your git repository within your new project folder by typing in git init. You will get a message that you created an empty repository and, depending how you have your terminal setup, you will have new text showing whether your git repository is up to date. After the repository is created, a green checkmark will appear that indicates there is nothing that needs to be pushed to Github. After you add a new file to your folder, the check mark changes to a red x and you can see a ?:1. This new line indicates you have 1 new change that can be pushed to Github.
3. Add the changes made by typing (git add .). This adds all changes. Then commit the changes by typing (git commit -m “a message describing your changes”). Now you’ll notice the red x changed back to a green arrow. This means the changes have been committed and are ready to be pushed to Github.
4. Create a Repository in github.com. You can do so by going to your account and hitting New repository.
5. The repository name should be the name of the folder you created in step 1. In this case I named it example_project. Then hit create repository.
6. Add the lines of code found in the (…or push an existing repository from the command line) to the terminal.
7. That’s it! Now all you need to do is commit and push changes to Github as you work on your project. Just follow the steps from before by using the following commands: git add ., git commit -m “description”, git push origin master.