How To Push Code To GitHub?

Create a GitHub repository

Open your terminal in your project folder

Initialize Git if needed: `git init`

Add files to staging: `git add .`

Commit your changes: `git commit -m “Initial commit”`

Add the remote repository: `git remote add origin https://github.com/username/repository.git`

Check the current branch name: `git branch`

Rename the branch to `main` if needed: `git branch -M main`

Push code to GitHub: `git push -u origin main`

Enter your GitHub credentials or token if prompted

Suggested for You

Trending Today