

# Pushes the changes in your local repository up to the remote repository you specified as the origin Push the changes in your local repository to. In Terminal, add the URL for the remote repository where your local repository will be pushed. To remove this commit and modify the file, use 'git reset -soft HEAD~1' and commit and add the file again.Īt the top of your repository on 's Quick Setup page, click to copy the remote repository URL. # Commits the tracked changes and prepares them to be pushed to a remote repository. To unstage a file, use 'git reset HEAD YOUR-FILE'.Ĭommit the files that you've staged in your local repository. # Adds the files in the local repository and stages them for commit. $ git init & git symbolic-ref HEAD refs/heads/mainĪdd the files in your new local repository. If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using & git symbolic-ref HEAD refs/heads/main. 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 master. Use the init command to initialize the local directory as a Git repository. You can add these files after your project has been pushed to GitHub.Ĭhange the current working directory to your local project. To avoid errors, do not initialize the new repository with README, license, or gitignore files.

For more information about possible arguments, see the GitHub CLI manual.Īdding a local repository to GitHub using GitĬreate a new repository on. 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. Stage and commit all the files in your project git add. Initialize the local directory as a Git repository. In the command line, navigate to the root directory of your project. Sensitive information can include, but is not limited to:įor more information, see " Removing sensitive data from a repository." Adding a local repository to GitHub with GitHub CLI Warning: Never git add, commit, or push sensitive information to a remote repository.
