Skip to main content

How to push your project to GitHub

Updated 6 min readMarkdown

I used to forget the steps to push my project inside my laptop to Github repository. Maybe because I rarely coding any projects, or I even tried to memorize the git commands instead to understand it.

However, I learned this in a fun way when I build personal vibe coding project in Cursor with the guidance from ChatGPT to help me understand what are those git commands for and how to push, commit, and initiate the new repository.

I wrote this in case I forget, and I always can back to read it again.

Check before initiate

First, I opened the terminal inside my VS Code then check for GitHub CLI by run these commands:

git --version 
gh --version

Luckily I already installed GitHub CLI few months ago.

I learned that lets you create GitHub repositories directly from the terminal, but I don't know yet if my GitHub account already signed in here. So, I run this command again:

gh auth login

Then in terminal asks me to choose github.com, HTTPS, and browser authentication when prompted. And before I continue uploading, ChatGPT suggested me to create or add this inside my .gitignore file:

# Dependencies
node_modules/

# Build output
dist/
build/

# Environment variables and secrets
.env
.env.*
!.env.example

# Logs
*.log
npm-debug.log*

# Local editor files
.vscode/
.idea/

# Operating system files
.DS_Store
Thumbs.db

I ensure my .gitignore file exists to prevent unnecessary files, large folders, and sensitive information from accidentally being uploaded to GitHub.

It keeps my repository clean, lightweight, secure, and easier to manage.

馃挕

Remember to not upload API keys, authentication tokens, passwords, or private .env files. Including the images or videos if your repository is open for public.

Once again I checked if my project already has Git initialized.

git status
git remote -v

Create new repository

Apparently Git reports that my file is not a repository, so I had to initialize it.

git init
git branch -M main

After I ran that commands, my Git is already initialized and I checked .env to show me an existing remote, I already ensured it won't push to wrong repository. Yet, I didn't follow ChatGPT guidance.

git config --global user.name "YOUR_GIT_NAME"
git config --global user.email "YOUR_GIT_EMAIL"

I skipped this part where later I got a problem because I think my GitHub account already signed in within VS Code鈥擨 thought I didn't need to do that.

So, I quickly ran another commands where my files already exist.

git add .
git status

And created my first commit

git commit -m "chore: initial workflow UI implementation"

Then created an annotated version tag鈥攖o help me see the changelog. This means the changes belong to that Version 1.0.0

git tag -a v1.0.0 -m "Version 1.0.0 - Initial workflow UI baseline"

Encounter the errors

After I made version tag git tag -a v1.0.0 ... successfully, I had errors because I made mistakes as I said earlier.

The gh repo create ... and git push origin v1.0.0 were failed because GitHub CLI isn't authenticated and the origin remote doesn't exist yet. I don't need to restart Git initialization, recreate your commit, or create another tag.

Here's five steps I did to fix it:

Step 1: Log in to GitHub

In the terminal I started to run this command again,

gh auth login

because apparently I hadn't log in any of my GitHub account yet, that's why I encountered the error in my command earlier. Then GitHub CLI shows this:

Questions Select
Where do you use GitHub? github.com
Preferred protocol HTTPS
Authenticate Git with GitHub credentials? Yes
How would you like to authenticate? Login with a web browser

It displayed a one-time code and ask me to press Enter to open the browser to log in my GitHub account with the access tokens inside my terminal.

Step 2: Verify my login

After completing my authentication, I did this

gh auth status

to see if I'm already logged in to github.com

Step 3: Create new repository (again)

Since there's no repository uploaded on my Github when I checked my profile, I needed to run the same command again:

gh repo create workflow-ui-component --private --source=. --remote=origin --push

That should create a new private repository, link it as origin, and push your existing commits.

Step 4: Push my Version 1.0.0 tag

Once the repository has been created successfully, I checked if it uploaded in my existing local version tag to GitHub

git push origin v1.0.0

Step 5: Confirm everything worked

I confirmed all things work inside my project by running this command:

git status
git remote -v
git tag

Then open the repository:

gh repo view --web

I could now see my project on GitHub, including its commit history and v1.0.0 tag. Further, I ran this:

gh auth login

Eventually I finally succeed creating the repository, but I found another problem I didn't expect, you can read here .


Save for future versions

Since I used Antigravity to vibe code my project, I have to remind myself every changes there must be pushed to GitHub, so I can have checkpoint.

ChatGPT suggested after fixing one single component or element in styling I should run this command again to make a commit:

git add .
git commit -m "fix: refine workflow card styling and connector handles"
git push origin main

Then if I was ready to update next version:

git tag -a v1.1.0 -m "Version 1.1.0 - Workflow visual refinements"
git push origin v1.1.0

Sources to learn more

  1. Git Guides - git init
  2. Git Init: How to Initialize and Set Up a Git Repository | DataCamp