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
- 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.
- Go to github.com and click New repository.
- Enter the repository name.
- Choose Public or Private.
- Do not initialize with README, .gitignore, or license.
- Click Create repository.
Copy the repository URL (e.g. https://github.com/your-username/your-repo.git).
cd /path/to/your/projectIf Git is not initialized:
git initA branch does not exist until the first commit.
git add .
git commit -m "Initial commit"Check the current branch:
git branchIf it shows master or main, rename it:
git branch -M developVerify:
git branchYou should see * develop.
git remote add origin https://github.com/your-username/your-repo.gitVerify:
git remote -vgit push -u origin developThe -u flag sets upstream tracking. After this, you can use:
git pushIf git branch shows nothing, create the first commit:
git add .
git commit -m "Initial commit"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| Branch | Purpose |
|---|---|
main |
Production-ready code |
develop |
Integration branch |
feature/* |
Feature branches |
Typical flow: feature → develop → main
Done. Your local project is on GitHub and tracks the develop branch.