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

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

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

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

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


当前回答

从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帐户名和你的存储库名称更改粗体部分。

其他回答

你只需要知道几个命令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”是每个用户都可以更改的名称

我花了1-2个小时才意识到我应该在GitHub上创建存储库,然后再尝试将我的本地文件推送到GitHub(或其他你正在使用的Git服务)。

在尝试推之后,错误如下:

remote: Repository not found.
fatal: repository 'https://github.com/username/project.git/' not found

我觉得自己像个白痴,但我真的想对像我这样的初学者强调这一点。我只是认为我的存储库将在第一次推送时自动创建。我大错特错了。

你可以用这个命令查看你的遥控器:

git remote -v

为了将一个新项目上传到Git中(首先你需要有项目的本地代码库和上传项目的Git存储库。在Git中,你需要有你的凭证)。

List item Open Git Bash Go to the directory where you have the code base (project location) cd to project location cd ////** Then here you need to execute Git commands. git init Press Enter then you will see something like this below. The initialized empty Git repository in ://****/***/.git/, so git init will initialize the empty Git repository at local git add . Press Enter The above command will add all the directories, subdirectories, files, etc. You will see something like this: warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. git commit -m "first commit" Press Enter. -m provided option for adding comment. It will commit the code to the stage environment. You will see some thing like this: [master (root-commit) 34a28f6] adding ******** warning: LF will be replaced by CRLF in c*******. The file will have its original line endings in your working directory. 27 files changed, 3724 insertions(+) create mode 100644 ***** create mode 100644 ***** create mode 100644 ***** git remote add origin http://username@git:repopath.git Press Enter. This will add to the repository. git push -u origin master Press Enter. This will upload all from local to repository in this step you need to enter password for the repository where you will be uploading the code. You will see some thing like this below: Counting objects: 33, done. Delta compression using up to 12 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (33/33), 20.10 KiB | 0 bytes/s, done. Total 33 (delta 14), reused 0 (delta 0) To http://username@git:repolocation.git \ [new branch] master -> master Branch master set up to track remote branch master from origin.

你需要一个SSH连接和GitHub初始化到你的项目。我将在Linux机器下解释。

让我们从一些简单的东西开始:在终端中导航到你的项目,并使用:

git init
git add .
git commit

现在让我们将SSH添加到您的机器中:

use

ssh-keygen -t rsa -C "your_email@example.com"

复制公钥,然后将其添加到你的GitHub存储库:

部署键->添加一个

回到你的机器项目,现在启动:

git push origin master

如果有一个错误,配置你的.github/配置文件

nano .github/config

并将URL更改为SSH的一个:

url = git@github.com:username/repo....

就是这样。

遵循以下两个步骤:

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

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