Pages

Sunday, 29 November 2020

Add Project to GitHub Using Git Base

Add Project to GitHub Using Git Bash (Step-by-Step Guide)

Follow the steps below to upload your local project to GitHub using Git Bash.


1. Create a New Repository on GitHub

  • Open GitHub
  • Click New Repository
  • Enter repository name
  • Click Create Repository

You will now see a set of commands provided for first-time setup.


2. Open Git Bash in Your Project Folder

To open Git Bash at the correct location:

  • Right-click your project folder
  • Select Git Bash Here

OR copy the project path manually:

  • Right-click the project folder
  • Select Properties → Resource → Location
  • Copy the full file path

3. Use the Git Commands Provided by GitHub

Navigate to Your Project Folder

cd "<path>"

Initialize Git

git init

Add GitHub Remote Repository

git remote add origin https://github.com/your-username/your-repo.git

(Use the remote URL shown on your GitHub repository page.)


If “Reinitialized existing Git repository” Appears

This means Git was already initialized earlier. It's better to remove the old Git folder and reinitialize:

rm -rf .git
git init

4. Add All Files to Git

git add .

Note: The dot (.) means add all files from the current folder.


5. Commit Your Changes

git commit -m "first commit"

6. Set Branch Name to main

git branch -M main

7. Push Code to GitHub

git push -u origin main

8. Refresh GitHub Repository

Your project files will now appear on your GitHub repository page.

-- Thanks --

No comments:

Post a Comment

Deploy Your Code to Heroku: Complete Guide (GitHub & Node.js)

Heroku provides a smooth workflow for deploying apps directly from GitHub or via Git. In this guide, you’ll learn both methods step-by-step....