-2

How to push a code from my local env to a brand new repository that does not have any branch yet.

Muazzam
  • 13
  • 1
  • 4
  • 1
    I'm not sure what you are asking. Are you asking how to add a new [remote](https://git-scm.com/docs/git-remote) to your repository? Or are you asking if [`git push`](https://git-scm.com/docs/git-push) can be used to push to a remote repository directly? – knittl May 12 '22 at 18:58
  • the second option. Git push to a remote repository directly. – Muazzam May 12 '22 at 19:36

1 Answers1

0

The syntax of git push is:

git push [options] [ […​]]

Repository can be a URL to a repository or the name of a configured remote in your repo.

To push local branch "a" to a repository at example.com/repo.git, execute

git push example.com/repo.git a

If you plan on doing that more than once, consider adding a remote:

git remote add examplerepo example.com/repo.git
git push examplerepo a
knittl
  • 246,190
  • 53
  • 318
  • 364