检查后,我如何上传我的项目的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

其他回答

遵循RishiKesh Pathak的指示。你甚至可以通过只插入一次这个命令行来缩短push命令:

git config --global push.default simple

所以下次不要使用git push origin master,你只需要:

git push

详情请点击这里。

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

我认为最简单的方法就是为Eclipse安装Git插件。它的工作原理或多或少与Eclipse CVS和SVN插件相同。

我这样做了;

git init Git添加。 git commit -m "Your_message" Git远程添加源@your_git_repository Git push -u origin master

当然,你必须安装Git。

我假设你和我一样使用Windows系统,并且安装了Git。您可以在项目目录中通过简单的命令提示符运行这些命令,也可以使用Git Bash。

步骤1:

在Git中手动创建一个存储库。随你怎么称呼它。

步骤2:

进入您的本地项目目录。如果您希望将代码发布到刚刚创建的新存储库中,请确保在项目根目录中没有文件夹名.git。如果有,请删除。 执行命令git init。

步骤3:

运行命令

转到添加 。

步骤4:

运行命令

git commit -m YourCommitName

步骤5:

运行命令

git远程添加YourRepositoryName https://github.com/YourUserName/YourRepositoryName.git

步骤6:

运行命令

git push——set-upstream YourRepositoryName master——force

请注意,我在撰写本文时使用的是最新版本的Git。还要注意,我没有指定要将代码推入的任何特定分支,所以它会进入master。在第6步中,Git会要求您在一个弹出窗口中输入用户名和密码来授权命令。