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

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

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

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

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


当前回答

尝试使用Git Bash来推送您的代码/进行更改,而不是直接在GitHub上上传文件(它不太容易出错,有时也很舒服-也需要更少的时间!)要做到这一点,你可以遵循以下步骤:

Download and install the latest version of Git Bash from here. Right-click on any desired location on your system. Click “Git Bash Here”. git config --global user.name “your name” git config --global user.email “your email” Go back to your GitHub account – open your project – click on “clone” – copy HTTPS link. git clone PASTE HTTPS LINK. A clone of your GitHub project will be created on your computer location. Open the folder and paste your content. Make sure content is not empty. Right-click inside the cloned folder where you have pasted your content. Click “Git Bash Here” again. You will find (master) appearing after your location address. git add . Try git status to check if all your changes are marked in green. git commit --m “Some message” 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

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

git config --global push.default simple

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

git push

详情请点击这里。

下载Sourcetree。

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

使用Git的最佳方式是实际启动giting。试试这个网站,它会让你一步一步地了解在命令行上执行功能的基本方法,以便在GitHub上推送项目。

这个叫做try.github.io,或者你也可以参加Codecademy的课程。