Automating and Securing Your Git Workflow with SSH in Windows CMD for a Repo Setup


Want to simplify your Git workflow on Windows? Here’s a straightforward guide to connect to your Git repo securely, create a new one, and push your code without the need for remembering or updating old passwords

Step 1: Open Command Prompt

Hit Win + R, type cmd, and press Enter.

Step 2: Install Git

If you don’t have Git, grab it from git-scm.com.

Step 3: Generate Your SSH Key with RSA algorithm

Run this command:

 ssh-keygen -t rsa -b 4096

Just hit Enter to stick with the default location. You can set a passphrase or skip it.

Step 4: Copy Your Public SSH Key

Open it in Notepad:

notepad C:\Users\YourUsername\.ssh\id_rsa.pub

Swap out YourUsername with your actual username. Copy that key!

Step 5: Add Your SSH Key to GitHub

Log in to GitHub. Head to Settings > SSH and GPG keys. Click New SSH key. Paste your key and save.

Step 6: Go to Your Project Directory

Use this command to navigate:

cd path\to\your\directory

Step 7: Initialize a New Repo

Run:

git init
Step 8: Stage Your Files

Add your files:

git add .

Step 9: Make Your First Commit

Commit with a message like this:

git commit -m "Initial commit"

Step 10: Link to Your Remote Repo (You need to create it first on Github)

Run this command:

git remote add origin git@github.com:yourusername/your-repo.git

then run

git branch --set-upstream-to=origin/master master

 

Step 11: Push Your Code

Finally, push your changes:

git push

Wrap Up

And that’s it! You’ve set up Git with SSH on Windows. Create repos and push code securely without the hassle. Keep it simple and happy coding!