如何将项目上传到 Github [英] How to upload a project to Github

查看:26
本文介绍了如何将项目上传到 Github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查 将我的项目上传到 github 后,我仍然不知道如何将项目上传到我的 Git Hub 存储库.

After checking Upload my project to github I still have no idea how to get a project uploaded to my Git Hub repository.

我是 GitHub 的新手,我不知道该怎么做.我创建了一个存储库,但我想将我的项目上传到其中.

I'm new to GitHub and I have no idea what to do. I created a repository but i want to upload my project to it.

我在存储库页面上查看了某种上传按钮,但没有看到任何此类内容.

I've looked on the repository page for an upload button of some kind but I haven't seen anything of the sort.

到目前为止,我已经查看了提供的链接,但仍然没有找到.他们提到了命令行,是 Windows 命令行还是 Git Bash?因为我不能让他们做任何事情.

I've looked at the links provided so far but I'm still getting no where. They mention command line, is that Windows command line or Git Bash? Because I can't get either to do anything.

我也尝试过使用 Git GUI,但是当我选择我想要的文件夹时,它说它不是 Git 存储库...是否需要压缩它?我尝试在文件夹中添加 .gitconfig 文件,但没有任何区别.

I also tried using Git GUI but when I select the folder I want it says that it's not a Git repository...does it need to be zipped up? I tried adding the .gitconfig file in the folder but it doesn't make a difference.

推荐答案

自从我写了这个答案,github 发布了一个原生的 windows客户端,这使得以下所有步骤变得多余.

Since I wrote this answer, github released a native windows client which makes all the below steps redundant.

您还可以使用 sourcetree 在 Windows 上获得 git 和 mercurial 设置.

You can also use sourcetree to get both git and mercurial setup on Windows.

以下是您在 Windows 中的操作方法:

Here is how you would do it in Windows:

  1. 如果您没有安装 git,请参阅这篇文章了解如何安装进行设置.
  2. 打开 Windows 命令提示符.
  3. 在命令提示符下切换到源代码所在的目录.
  4. 首先,在这个目录中创建一个新的仓库git init.这将显示 在 ....git 中初始化空 git 存储库"(... 是路径).
  5. 现在您需要通过将文件添加到您的存储库来告诉 git 您的文件.使用 git add filename 执行此操作.如果要添加所有文件,可以执行 git add .
  6. 现在您已经添加了文件并进行了更改,您需要提交您的更改,以便 git 可以跟踪它们.输入 git commit -m 添加文件".-m 允许您在行中添加提交消息.
  1. If you don't have git installed, see this article on how to set it up.
  2. Open up a Windows command prompt.
  3. Change into the directory where your source code is located in the command prompt.
  4. First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path).
  5. 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 .
  6. 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.

So far, the above steps is what you would do even if you were not using github. They are the normal steps to start a git repository. Remember that git is distributed (decentralized), means you don't need to have a "central server" (or even a network connection), to use git.

现在您想将更改推送到由 github 托管的 git 存储库.您可以通过告诉 git 添加远程位置来完成此操作,然后使用以下命令执行此操作:

Now you want to push the changes to your git repository hosted with github. You do this by telling git to add a remote location, and you do that with this command:

git remote add origin https://github.com/yourusername/your-repo-name.git

*注意:your-repo-name 应该在你做 git remote add origin ... 之前在 GitHub 中创建完成后,git 现在知道您的远程存储库.然后,您可以告诉它推送(即上传")您提交的文件:

*Note: your-repo-name should be created in GitHub before you do a git remote add origin ... Once you have done that, git now knows about your remote repository. You can then tell it to push (which is "upload") your commited files:

git push -u origin master

这篇关于如何将项目上传到 Github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆