检查后,我如何上传我的项目的Git存储库到GitHub?,我仍然不知道如何让一个项目上传到我的GitHub存储库。

我创建了一个存储库,并想将我的项目上传到它。

我在存储库页面上查看了某种上传按钮,但我没有看到任何类似的东西。

到目前为止,我已经查看了提供的链接,但仍然一无所获。他们提到了命令行;是Windows命令行还是Git Bash?因为我不能让他们做任何事。

我也尝试使用Git GUI,但是当我选择我想要的文件夹时,它说它不是Git存储库…需要拉上拉链吗?我尝试在文件夹中添加.gitconfig文件,但没有什么不同。


当前回答

Open Git Bash. Change the current working directory to your local project. Initialize the local directory as a Git repository: $ git init Add the files in your new local repository. This stages them for the first commit: $ git add . Commit the files that you've staged in your local repository: $ git commit -m "First commit" At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. In the Command prompt, add the URL for the remote repository where your local repository will be pushed : $ git remote add origin remote repository URL Push the changes in your local repository to GitHub: $ git push origin master

其他回答

你只需要知道几个命令im cmd推或拉任何目录到/从github。 命令来推送/上传任何项目或代码到git集线器。

首先到达需要上传的工作目录或项目目录。

检查正确的工作目录

ls

初始化目录下的git

git init

检查git init是否工作

ls -a //this command shows hidden files

使用上述命令,您将发现文件添加到您的目录。

 ./   ../   .git/ 

上面的命令不是可以跳过的。 现在添加工作目录的文件提交

git add . 

然后使用commit命令并命名该commit以供参考

git commit -m "Commit Name"

在最后一步之前,你需要去github网站,创建一个新的存储库,并复制存储库的url

git remote add main https://github.com/username/repositoryName.git

现在命令上传目录

git push -u main

注意:名称“main”是每个用户都可以更改的名称

使用Git的最佳方式是实际启动giting。试试这个网站,它会让你一步一步地了解在命令行上执行功能的基本方法,以便在GitHub上推送项目。

这个叫做try.github.io,或者你也可以参加Codecademy的课程。

从Visual Studio Code上传一个项目到GitHub

要使用Visual Studio Code在GitHub中上传项目,请遵循以下步骤。

打开Visual Studio代码。如果你没有VSCode下载:下载Visual Studio Code 在VSCode打开文件>打开文件夹.. 进入终端—>新终端 请依次执行以下命令

git init

转到添加 。

git commit -m“第一次提交”

Git远程添加origin https://github.com/yourusername/your-repo-name.git

Git push origin master

注意:在上面的命令git remote add origin https://github.com/yourusername/your-repo-name.git中,请用你的GitHub帐户名和你的存储库名称更改粗体部分。

遵循以下两个步骤:

使用链接:https://github.com/new在线创建存储库 然后使用命令将本地回购链接到远程回购:git add remote origin https://github.com/userName/repo.git 这里是回购。Git将是您新创建的远程repo。

这将非常有效。不需要担心SSH或HTTPS方式。我第一次遇到同样的问题,花了几个小时来解决。 但这对我很管用。

按照以下步骤将项目上传到GitHub:

git init Git添加。 添加我所有的文件 Git远程添加origin https://github.com/yourusername/your-repo-name.git 上传的项目从零开始需要git拉源主。 Git拉源主 Git push origin master