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

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

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

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

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


当前回答

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

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

其他回答

遵循以下两个步骤:

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

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

为了将一个新项目上传到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.

这对我很管用;

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

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

GitHub发布了一个本地Windows客户端,使以下所有步骤变得多余。

您还可以使用Sourcetree在Windows上获得Git和Mercurial的设置。


下面是你在Windows下的操作方法:

If you don't have Git installed, see this article on how to set it up. Open up a Windows command prompt. Change into the directory where your source code is located in the command prompt. First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path). Now you need to tell Git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add . Now that you have added your files and made your changes, you need to commit your changes so Git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.

到目前为止,即使你不使用GitHub,上面的步骤也是你要做的。它们是启动Git存储库的正常步骤。请记住,Git是分布式的(去中心化的),这意味着使用Git不需要“中央服务器”(甚至不需要网络连接)。

现在,您希望将更改推到GitHub托管的Git存储库中。你可以通过告诉Git添加一个远程位置来做到这一点,你可以用下面的命令来做到:

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

*注意:在你做git远程添加origin之前,你应该在GitHub中创建your-repo-name…

完成此操作后,Git现在就知道远程存储库了。然后你可以让它推送(也就是“上传”)你提交的文件:

Git push -u origin master