Let’s first understand what is Git, GitHub and Git Bash.
Git — Git is a DevOps tool used for source code management in software development. It is free and open source version control system used to handle small to large projects efficiently.
GitHub — GitHub is an open source repository hosting service that provides a web-based graphical interface. GitHub repository contains all project’s files and each file’s revision history.
Git Bash — Git Bash is an application for Microsoft Windows, allowing developers to use Git in a command-line interface.
This article will show you steps on “How to upload project folder to GitHub repository with Git Bash”.
1. Create an account on https://github.com/
2. Sign in to your GitHub account and click on Repositories →New. Enter repository name and click on Create repository.
3. Download git from https://git-scm.com/downloads for your operating system. Run .exe file and install git.
4. After installing Git, search for Git Bash in the start menu. Press Enter to launch the app.
Alternatively you can open Git Bash by right clicking on desktop.
5. Connect to repository by using GitHub credentials with the following commands.
git config - -global user.email “email used for GitHub account”
git config - -global user.name “user name of GitHub account”
6. Git Bash commands to upload source code files to GitHub Repo:
cd command allows you to change the directory.
Syntax — cd “C:\Users\eclipse-workspace\sample”
The git init command creates an empty .git repository or reinitializes an existing one.
Syntax — git init
Before running git push command, make sure your repository is set as origin.
Syntax — git remote add origin <GitHub repository link>
The git add command updates the index with the content in the working tree and prepares the content in the staging area for commit.
Syntax — git add .
The git commit command instructs Git to store that file version. Git only commits the changes made in the repository.
Syntax — git commit -m “Commit message”
The git push command sends files from the local repository to the remote repository.
Syntax — git push origin master
7. After executing the above commands, refresh your GitHub repository page and you will see the entire project folder is uploaded to GitHub.
This was the brief introduction to the source code files upload functionality using Git Bash with Git and GitHub. You could benefit from Git as a way to keep track of your work, collaborate with others, and avoid programming disasters due to unintended deletion or overwriting of files.