git init repo
git init git add somefile git commit -m "initial commit" git remote add origin https://github.com/username/new_repo git push -u origin master
Source: kbroman.org
how to initialize a git repository command line
# New local repository git init git add . git commit -m "Initial commit" # New remote repository git remote add origin git@github.com:username/new_repo #ssh # Now push git push -u origin master
connect project to git repository
git init -b main git add . && git commit -m "initial commit" To create a repository for your project on GitHub, use the gh repo create subcommand. When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository. If you want your project to belong to an organization instead of your user account, specify the organization name and project name with organization-name/project-name Alternatively, to skip all the prompts, supply the path to the repository with the --source flag and pass a visibility flag (--public, --private, or --internal). For example, gh repo create --source=. --public. Specify a remote with the --remote flag. To push your commits, pass the --push flag. For more information about possible arguments, see the GitHub CLI manual.