Skip to content

Latest commit

 

History

History
148 lines (94 loc) · 2.56 KB

File metadata and controls

148 lines (94 loc) · 2.56 KB

Push local project to GitHub (develop branch)

Single-topic guide: Create a new GitHub repository and push an existing local project to a remote develop branch (without initializing the repo with README, .gitignore, or license on GitHub).

Git Handbook — back to all guides


What you'll do

  • Create a new repo on GitHub (do not add README, .gitignore, or license).
  • Initialize Git locally, make the first commit, and rename the current branch to develop.
  • Add the remote and push with upstream tracking.

Steps

1. Create a new repository on GitHub

  1. Go to github.com and click New repository.
  2. Enter the repository name.
  3. Choose Public or Private.
  4. Do not initialize with README, .gitignore, or license.
  5. Click Create repository.

Copy the repository URL (e.g. https://github.com/your-username/your-repo.git).


2. Initialize Git in your local project

cd /path/to/your/project

If Git is not initialized:

git init

3. Add files and create the first commit

A branch does not exist until the first commit.

git add .
git commit -m "Initial commit"

4. Rename the current branch to develop

Check the current branch:

git branch

If it shows master or main, rename it:

git branch -M develop

Verify:

git branch

You should see * develop.


5. Add the remote repository

git remote add origin https://github.com/your-username/your-repo.git

Verify:

git remote -v

6. Push to the remote develop branch

git push -u origin develop

The -u flag sets upstream tracking. After this, you can use:

git push

🔎 Common issues

No branch appears

If git branch shows nothing, create the first commit:

git add .
git commit -m "Initial commit"

Remote repository already has a README

If you initialized the GitHub repo with a README, you may see:

error: failed to push some refs

Fix by allowing unrelated histories, then push:

git pull origin main --allow-unrelated-histories
git push origin develop

📌 Recommended Git workflow

Branch Purpose
main Production-ready code
develop Integration branch
feature/* Feature branches

Typical flow: featuredevelopmain


Done. Your local project is on GitHub and tracks the develop branch.