Push Your Code To GitHub โฌ†๏ธ

Push Your Code To GitHub โฌ†๏ธ

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 select New repository

1.png


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 of gitignore from the dropdown menu
  • If you want you can Choose a license
  • Then press the Create Repository button.

2.png

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

3.png

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)

4.png

  • It will ask some questions just press "Enter" and it will generate a new key

5.png

  • Now you can see the key is generated.

  • Now you have to find your public key path

6.png

  • Copy that path from the terminal / Gitbash.
  • Write cat command & paste that path there
cat <your key path>
  • It will give you your key

7.png

  • Now copy that key & open Github go to settings

8.png

  • Select SSH and GPG keys from the left side nav bar.

9.png

  • Press the New SSH Key button.
  • paste your SSH key there and give it a Title

10.png

  • 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.

11.png

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.

12.png

Checking Status

git status
  • This command will show us the list of which files are staged unstaged and untracked.

13.png

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

14.png

Add origin

3.png

  • 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.

15.png

Add Branch

git branch -M main
  • This command will create a new branch main

16.png

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

17.png


DONE ! Congratulations!!

Screenshot from 2022-07-26 10-27-48.png

  • 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

ย