Git & GitHub 000: Basics
Here are the steps to push code to a GitHub repository:
- Create a GitHub account and log in.
- Create a new repository by clicking the “New” button in the top-right corner of the dashboard.
- Give your repository a name and a brief description, then click the “Create repository” button.
- Open a terminal or command prompt, and navigate to the local directory where you want to store your code.
- Initialize the local directory as a Git repository by running the following command:
git init
6. Add the files in your local repository and stage them for commit. To do this, run the following command:
git add .
7. Commit the staged files to the local repository. This creates a snapshot of the files in their current state, along with a message describing the changes. To commit the files, run the following command:
git commit -m "commit message"
8. Add the URL of the remote repository as a remote for your local repository. To do this, run the following command, replacing <remote_repo_url> with the URL of your remote repository:
git remote add origin <remote_repo_url>
9. Push the committed changes to the remote repository. To do this, run the following command:
git push origin master
This will push the code in the local repository to the remote repository on Github.
I hope you enjoyed this introduction to Git & Github!