

For more information about possible arguments, see the GitHub CLI manual. To create a repository for your project on GitHub, use the gh repo create subcommand. To push your commits, pass the -push flag. To add the remote and push the repository, confirm yes when asked to add the remote and push the commits to the current branch.Īlternatively, to skip all the prompts, supply the path to the repository with the -source flag and pass a visibility flag ( -public, -private, or -internal). 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.įollow the interactive prompts. When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository. To create a repository for your project on GitHub, use the gh repo create subcommand.

If you’re using Git 2.28.0 or a later version, you can set the name of the default branch using -b. By default, the initial branch is called main.

Initialize the local directory as a Git repository. Navigate to the root directory of your project. If your project is already tracked by Git, skip to " Importing a Git repository with the command line."
#Git push files to new repository code#
If your locally-hosted code isn't tracked by any VCS, the first step is to initialize a Git repository. Sensitive information can include, but is not limited to:įor more information, see " Removing sensitive data from a repository." Initializing a Git repository Warning: Never git add, commit, or push sensitive information to a remote repository.
