Table of contents
- If you want to learn git then check this blog
- Step 1 : (Download Git)
- Step 2 : (Open an Account on GitHub)
- Step 3 : (Create a new repository)
- Step 4 : (Give repository details)
- Step 5 : (Git repository created)
- Step 6 : (Generate an SSH key)
- Step 7 : (Setting up a global username and email)
- Step 8 : (Adding the project to the local repository and pushing it to remote repository )
Want to push your code to GitHub but don't have time to learn Git? Then this is the best blog for you. The purpose of this blog is not to teach you how git commands. I just want to show you that if you want to upload a project on Github how can you do it.
If you want to learn git then check this blog
Step 1 : (Download Git)
- Click Here to download Git.
- Select your OS download git & install it.
Step 2 : (Open an Account on GitHub)
Click Here to create an account on GitHub
give your details here & Signup
Step 3 : (Create a new repository)
- Click here on this
+
icon and selectNew repository
Step 4 : (Give repository details)
- write the name of your new
repository
- Select repository type
- Public: Everyone can see your repository
- Private: Only you can see or If you give permission to others they can see your repository
- If you want a readme file then press the
Add a README file
checkbox - If you want a
.gitignore
file then press select the type ofgitignore
from the dropdown menu - If you want you can
Choose a license
- Then press the
Create Repository
button.
In this image I'm creating a public repository(furry-guacamole)
Step 5 : (Git repository created)
- After pressing the
Create Repository
button you will be redirected to your repository
Congratulations! you created your first repository.
Step 6 : (Generate an SSH key)
- Now you have to Generate an SSH key without that you can't upload anything to GitHub.
ssh-keygen -t ed25519 -C "your_email@example.com"
open your terminal or Gitbash this command to generate your ssh key (removeyour_email@example.com
& put your email there)
- It will ask some questions just press "Enter" and it will generate a new key
Now you can see the key is generated.
Now you have to find your public key path
- Copy that path from the terminal / Gitbash.
- Write
cat
command & paste that path there
cat <your key path>
- It will give you your key
- Now copy that key & open Github go to settings
- Select
SSH and GPG keys
from the left side nav bar.
- Press the
New SSH Key
button. - paste your
SSH
key there and give it aTitle
- Press the
Add SSH Key
button.
Step 7 : (Setting up a global username and email)
- Open your terminal or Gitbash again
- paste these two commands one by one
git config --global user.name "Your Name"
git config --global user.email youremail@email.com
Don't forget to put your name & email
Step 8 : (Adding the project to the local repository and pushing it to remote repository )
- Open your project folder.
- Open your terminal or Gitbash there & copy and paste these commands one by one.
Initialize Git
git init
- This command will initialize the .git folder in your project.
Add changed files
git add <file name>
- This command will stage only the specified changes for the next commit.
- or if you have many files use this command instead
git add .
- This command will stage all files for the next commit.
Checking Status
git status
- This command will show us the list of which files are staged unstaged and untracked.
Commit
git commit -m "Initial commit"
- This command will commit the changes.
-m
is a flag. If we want to add any message with commit we have to use-m
Add origin
- from here you can copy your origin
git remote add origin <your origin>
use your project's origin (link)
- This command will connect your remote repository to your local repository.
Add Branch
git branch -M main
- This command will create a new branch
main
Push the Code to the main
branch
git push -u origin main
- This command will push new changes into your remote repository from your local repository
DONE ! Congratulations!!
- Now you can share your project's link to others & they can see it.
Please don't use my Key or Details
Hopefully, now you upload any project to Github & If you want to learn the basics of git then check this blog.If you face any difficulties please let me know