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

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

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

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

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


当前回答

这对我很管用;

1- git init
2- git add .
3- git commit -m "Add all my files"
4- git remote add origin https://github.com/USER_NAME/FOLDER_NAME
5- git pull origin master --allow-unrelated-histories
6- git push origin master

其他回答

下载Sourcetree。

它适用于Windows 7(及更高版本)和Mac,强烈建议通过交互式UI在GitHub上上传文件。

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

你需要一个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....

就是这样。

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