Pages

Getting Started (2)

Other Pages (2)

Git Repo Start Here

Assuming you have a local project folder that you want to put on GitHub, here are the steps:


1. Create the Remote Repository on GitHub

Before running any commands, go to your GitHub account and create a new, empty repository.

  1. Go to https://github.com/new.

  2. Enter the Repository name (e.g., my-project).

  3. Choose Public or Private.

  4. Crucially, do NOT check any boxes for "Initialize this repository with a README," ".gitignore," or "Choose a license." You want the remote repository to be completely empty.

  5. Click Create repository.

On the next screen, GitHub will display instructions. You'll use the commands provided in the next section.


2. Initialize and Push from Your Local Project

Open your terminal or command prompt, navigate to your local project folder (e.g., cd ~/Documents/my-project), and run the following commands. Replace REPO_NAME.git with the actual name and URL of the repository you just created.

Step Command Description
Initialize git init -b main Turns the current directory into a Git repository and names the initial branch main.
Stage Files git add . Adds all files in the current folder to the staging area for the first commit.
Commit git commit -m "Initial project commit" Creates the first snapshot (commit) of your project's history.
Add Remote git remote add origin https://github.com/gregdyche/REPO_NAME.git Links your local repository to the new empty repository on your GitHub account. origin is the standard name for the remote.
Push git push -u origin main Pushes your local commits to the remote repository. The -u flag sets the remote branch as the default "upstream" for future git push and git pull commands.

Your local project is now synced with GitHub.


 

💡 Alternative: Using an Existing GitHub Project

If you already created a repository on GitHub (with a README, etc.) and want to start working on it locally, the best method is to clone it.

  1. Navigate to the directory where you want to keep your project files (e.g., cd ~/Documents/GitHub).

  2. Run the git clone command using the repository's HTTPS URL:

Bash
git clone https://github.com/gregdyche/REPO_NAME.git

This command will:

  • Create a local copy of the repository in a new folder (REPO_NAME).

  • Initialize it as a Git repository (git init).

  • Automatically configure the remote called origin.

You can then navigate into the new folder (cd REPO_NAME) and start working.