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

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

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

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

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


当前回答

首先,你必须在GitHub上创建一个账户 然后创建一个新项目-按您的需要命名该项目,然后显示您的项目URL 现在复制URL 然后打开命令提示符,使用cmd进入要上传的目录或文件夹 然后输入以下命令 git init Git添加。 Git commit -m "初始提交" git远程添加原点粘贴URL Git push -u origin master 现在检查你的GitHub账户。上传存储库成功。

要获得完整的指导,你可以观看这个视频。

其他回答

确保系统上安装了Git。我正在用windows操作系统解释这个过程[尽管它不应该是依赖于操作系统的工作]

以下是我的做法:

Open the cmd (you can do with git bash as well if you've installed git bash). Go to your project directory (where your project is located, it's essentially changing to directory either usiing cd path or through manual folder navigation). Now type git init. This will initialize an empty repository if it is first time and Enter. For example: git init Now type git add <filename>(if specific file) or git add <filename1> <filename2> <filenameN> (if specific but more than one files) or git add . (if you want to add all files) and enter. Now type git commit -m "commit message goes here" and enter. (in case if you need to check the status you can do by typing git status) and enter. Now type git remote add origin git_repository_url (check git remote -v go check remote repository) and Enter. Now it's turn to push it to the remote repository [essentially taking all the changes from local git to cloud(github) ...git push origin master and enter (if you get error you push it forcefully by typing ...git push -f origin master and enter.

注意:master是你的主分支的名称。如果您有多个分支,请确保选择相应的分支名称。

现在,您已经完成了将它从本地计算机添加到远程存储库的工作。刷新它,它将出现在您创建的存储库的选定分支中。

遵循以下两个步骤:

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

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

我这样做了;

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

当然,你必须安装Git。

上传项目到Git的步骤:

步骤1 -打开cmd并将当前工作目录更改为您的项目位置。

步骤2 -将项目目录初始化为Git存储库。

git init

步骤3 -在本地存储库中添加文件。

add .

步骤4 -提交您在本地存储库中暂存的文件。

git commit -m "First commit"

步骤5 -复制远程存储库URL。

步骤6 -在本地位置中添加远程存储库URL作为源。

git add origin copied_remote_repository_url

步骤7 -确认您的来源是否更新。

git remote show origin

第8步-推更改到您的GitHub存储库

git push origin master.

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