
AshuraMajestic
Jul 17, 2024
4 min
This guide will make you learn how you can push your project on the github using cmd
Open the Command Prompt (cmd) or terminal.
Check if Git is installed:
git --version
If Git is installed, this command will return the version number. Now close the cmd or terminal.
Open your project directory in cmd, VS Code terminal, or any terminal you prefer:
cd path/to/your/project
Check if Git is already initialized in your project:
git status
If Git is not initialized, follow these steps:
Initialize Git:
git init
Add all files in the folder you want to push:
git add .
If you have files or directories you do not want to push (e.g., node_modules), create a .gitignore file and specify these paths:
echo "/node_modules" > .gitignore
git add .gitignore
Commit the added files:
git commit -m "Initial commit"
Create a new repository on GitHub. Copy the repository URL.
Add the remote repository:
git remote add origin https://github.com/yourusername/your-repo.git
Open Git Bash and generate an SSH key:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Press Enter to accept the default file location. You will be prompted to enter a passphrase (optional).
Start the SSH agent:
eval $(ssh-agent -s)
Add your SSH key to the agent:
ssh-add ~/.ssh/id_rsa
Copy your SSH key to the clipboard:
cat ~/.ssh/id_rsa.pub
Copy the output.
Go to your GitHub account settings. Navigate to "SSH and GPG keys," click "New SSH key," add a title, and paste your SSH key. Click "Add SSH key."
Test the connection:
ssh -T git@github.com
You should see a message confirming the successful connection.
Push your code to GitHub:
git push -u origin master
(If you are using a branch other than master, replace master with your branch name.)
After making changes to your project, add and commit your changes:
git add .
git commit -m "Describe your changes"
Push your changes:
git push
Now, if you visit your GitHub repository, you should see your code.