First Push โ€” Full Workflow
Note: Replace the remote URL with your actual GitHub repository URL. Make sure the repo exists on GitHub first.
1
Initialize a new git repository
$git init
2
Add a remote origin (your GitHub repo URL)
$git remote add origin git@github.com:username/repo.git
3
Stage all files
$git add .
4
Create the first commit
$git commit -m "first commit"
5
Rename current branch to main
$git branch -M main
6
Push and set upstream
$git push -u origin main

Everyday Push Workflow
Check status of changes
$git status
Stage all changes
$git add .
Commit with a message
$git commit -m "your message here"
Push to main
$git push origin main
Pull latest changes from remote
$git pull origin main

Useful Git Extras
View commit log (one line each)
$git log --oneline
View all remotes
$git remote -v
Create and switch to a new branch
$git checkout -b feature/my-feature
Undo last commit (keep changes staged)
$git reset --soft HEAD~1
Clone a repository
$git clone git@github.com:username/repo.git