I don't know like to create a new repository.
I need to finish a project but I don't understand anything about the repository creation step.
CodePudding user response:
If you have a pre-existing codebase on your machine (which I assume is the case), and you need to "upload" this codebase to GitHub, then you would need to perform a few actions:
Create a new repo on GitHub. If you are not familiar with the command line, I suggest doing it on the Web UI. You should follow the link in @Ben's answer:
Ensure you are copying the
https
URL. Thessh
type URL requires a little bit more configurations, and you can do this when you are more comfortable with working withgit
andssh
tooling.Then run the following command:
git remote add origin <your repo url>
You can read more about git repo, remote repo and local repo here
Commit and push your code.
git commit -a -m "initial commit" git push origin main # you will be required to enter your username and password
GitHub requires you to use a Personal Access Token if you are pushing your code in the command line. You can refer to this link to create a PAT for yourself.
The next step for you should be learning more about the git
tooling. I would recommend reading Atlassian's git tutorial, or the Git book
CodePudding user response:
to create a repository, you will need to install git and sign up for an account on github.
You can find out more here, https://docs.github.com/en/get-started/quickstart/create-a-repo
I suggest that you watch or read through 1 or 2 guides on git and github before you create your repository.
CodePudding user response:
If you new repository is one you want to create locally and on Github, you can do so easily with the GitHub CLI gh
.
Once installed, authenticate yourself with gh auth login
, then create your new repository with gh repo create
If you don't have a repository yet:
# create a new remote repository and clone it locally
gh repo create my-project --public --clone
If you already have a repository locally:
# create a remote repository from the current directory
cd /path/to/my/local/repository
gh repo create my-project --private --source=. --remote=upstream
git push -u main
Use --public
or --private
depending on the visibility you want to associate to the new GitHub repository.