How to push a new project to github
Here's a step-by-step guide on how to push a new project to GitHub:
Prerequisites:
- You have a GitHub account and have created a new repository (repo) for your project.
- You have cloned the repository to your local machine using Git.
- You have created a new project folder on your local machine and initialized a Git repository in it using
git init
.
Step 1: Add files to your local repository
- Navigate to your project folder in your terminal or command prompt.
- Add all the files in your project folder to the Git repository using
git add.
(dot at the end). This will stage all the files in your project folder. - Verify that all files are staged using
git status
.
Step 2: Commit changes
- Commit your changes using
git commit -m "Initial commit"
(replace "Initial commit" with a meaningful commit message). - Verify that your commit is successful using
git log
.
Step 3: Link your local repository to your GitHub repository
- Navigate to your GitHub repository and copy the URL of your repository (it should be in the format
https://github.com/your-username/your-repo-name.git
). - In your terminal or command prompt, navigate to your project folder and run
git remote add origin <copied-url>
(replace<copied-url>
with the URL you copied from GitHub). - Verify that the remote repository is linked using
git remote -v
.
Step 4: Push your changes to GitHub
- Push your changes to your GitHub repository using
git push -u origin master
(replacemaster
with the name of your branch if it's not the default branch). - You will be prompted to enter your GitHub credentials (username and password).
- Once the push is successful, you should see a confirmation message indicating that your changes have been pushed to GitHub.
Step 5: Verify your changes on GitHub
- Navigate to your GitHub repository and verify that your changes have been successfully pushed.
- You should see your files and commit history reflected in your repository.
That's it! You have successfully pushed your new project to GitHub.