Upload Code To Github Repository Using Git Bash - FreeCodeBlog

Last updated: Dec 16, 2021

Do you have any code that needs to be uploaded to the GitHub repository? Yes! Do you want to upload the code for the first time to the GitHub repository? Yes! Okay don't worry, It doesn't matter how many times you want to upload new or existing code projects to the GitHub repository. After reading this tutorial, you can easily upload project code to GitHub repository as much as you like. To upload the code you may need to create a GitHub account, a new GitHub repository. You may also need to install Git Bash to upload the code to the repository. Now let's see what kind of information we might need to keep the code in the new GitHub repository.

 

Upload Code To Github Repository Using Git Bash
Upload Code To Github Repository Using Git Bash.

 

1. Create GitHub New Repository.

Do you have a created GitHub repository? No! Oh shit! Friends, you can't actually upload code to the GitHub repository without creating a GitHub repository. So first you need to create a GitHub repository to continue this tutorial. Don't know how to create a new GitHub repository? No! Don't worry, I have a solution to this problem. You can create a new GitHub repository by clicking "New Repository" from the GitHub profile. If you don't know how to create a new GitHub repository, you should read how to create a GitHub repository tutorial as soon as possible to continue upload code using git bash on GitHub repository. You can create public or private GitHub repositories to upload code project. You should use public GitHub repository for the first time.

 

2. Install Git Bash.

Do you have an installed git bash? No! OK then you need to install Git Bash on your device to upload project code to GitHub repository. So if you haven't installed git bash on your laptop or computer then you need to read how to install git bash on devices tutorial before continue this tutorial. I recommend that you download the latest version of Git Bash from the git-scm website to install it on your device.

 

3. Create Code.

If you do not have any generated code to upload to the GitHub repository, you will need to create the code on your device first. So do you have any generated code? No!. Okay then let's start to create code on your device. First create a new folder (Git-Repo) on your laptop or desktop then open it. Now let's create a new HTML file (index.html) into created folder (Git-Repo). Now open HTML file (index.html) and write some HTML code into HTML file (index.html) and then save HTML file.

 

<!doctype html>
<html lang="en">
<head>
<title>Upload Code To Github Repository Using Git Bash</title>
</head>
<body>
<div>
<p>Here's you need to write some paragraph</p>
</div>
</body>
</html>

 

4. Created GitHub Repository Info.

Have you created a GitHub repository? Yes. Okay have you read the GitHub repository information created? No. Don't worry friends, Now I'm going to explain the GitHub repository information created here. I'm going to upload the code to the GitHub repository using Git Bash, So you need to read push an existing project section from created GitHub repository. You will get git setup information after created new GitHub repository. Use “…or push an existing repository from the command line” information to upload your git project on GitHub.

 

5. Upload Code To GitHub Repository.

Are you ready to upload the code to the GitHub repository? Yes!. Good. I hope you have an installed git bash and created GitHub repository. Now go to created new folder (Git-Repo). Next right click and click on git bash here to open git bash pop-up. Now follow next steps carefully. I hope you did create a file that you want to upload on GitHub public or private repository. Now you need to run git init command using git bash to start using git version control in your code project.

 

git init

 

Did you run git init command? Yes!. Can you see a (.git) folder into Git-Repo folder? Yes. Okay now you need to run git add command. But why? Actually git add command will add all folder and files that are stored under (Git-Repo) folder.

 

git add .

 

Want to see current git status? You can run git status command any time after start to using git version control into your code project. Now you should run git status command to see (index.html) was added or not. If you can see green line color of (index.html) file then you need to follow next steps.

 

git status

 

Did you add all the folders and files to Git using git add command? Yes. Okay now you need to run git commit command. So let's commit the changes files after run git add command. Okay run git commit command to add message for commit.

 

git commit -m "Upload Code To Github Repository Using Git Bash"

 

Did you create the GitHub public repository? Yes. Do you have public repository information that you created? Yes. Good. Now are you ready to push your code to GitHub repository? Yes. Now you need to run git remote origin command. Please don't forget to use your created GitHub repository information to upload code to GitHub repository using git bash.

 

git remote add origin https://github.com/username/repository-name.git

 

Finally you need to push your exiting code to GitHub repository using git push command. Wait a minute, Do you know your git branch name? No. OK, you'll see the name of a branch in the Git Bash terminal. Branch name can be master, main.  So use your git branch that you want to push on GitHub repository using git bash.

 

git push -u origin branch-name (master, main)

 

Okay so this is for today. See you again next tutorials. Thanks

Post Tags
Post Writer
masum7323
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
Recover Data From Automatic Repair Laptop Or Desktop Using Windows 10 Cmd

Recover your all importance data from automatic repair loop stuck laptop or desktop. If your laptop stuck on automatic repair and your laptop hard... Read More

Make A Bootable Pendrive To Install Windows 10 On Mbr Disk Using Rufus

Use Rufus software easily to make a bootable pendrive to install Windows 10 on MBR disk. You need a minimum 8GB pendrive to make a MBR bootable pen... Read More

Identify Efi Or Boot Partition In Windows 10

Identify EFI or boot partition in windows 10. Open windows 10 cmd as a adminstration to checking EFI or boot partition. After opening cmd as admins... Read More

Download And Install Xampp And Composer On Windows 10 To Create Laravel Web Application

Hello guys, Read this tutorial carefully if you really want to develop your laravel skill. You need to download and install composer and xampp on y... Read More

How To Install Windows 10 Using Bootable Pendrive In Laptop Or Desktop

Install windows 10 using bootable pendrive in laptop or desktop. To install windows 10 you need to make a bootable pendrive using minimun 8GB pendr... Read More