git 将文件添加到 GitHub 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7555551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:56:13  来源:igfitidea点击:

Adding files to a GitHub repository

gitgithub

提问by user382738

How do I add files to my GitHub repository? I'm using Windows and all my project files are in one folder and I just need to upload it to my repo.

如何将文件添加到我的 GitHub 存储库?我使用的是 Windows,我所有的项目文件都在一个文件夹中,我只需要将它上传到我的仓库。

回答by VonC

The general idea is to add, commit and push your files to the GitHub repo.

总体思路是将文件添加、提交和推送到 GitHub 存储库。

First you need to clone your GitHub repo.
Then, you would git add all the files from your other folder: one trick is to specify an alternate working tree when git add'ing your files.

首先,您需要克隆您的 GitHub 存储库。
然后,您将 git add 其他文件夹中的所有文件:一个技巧是在 git add'ing 文件时指定备用工作树。

git --work-tree=yourSrcFolder add .

(done from the root directory of your cloned Git repo, then git commit -m "a msg", and git push origin master)

(从您克隆的 Git 存储库的根目录完成,然后git commit -m "a msg", 和git push origin master

That way, you keep separate your initial source folder, from your Git working tree.

这样,您就可以将初始源文件夹与 Git 工作树分开。



Note that since early December 2012, you can create new files directly from GitHub:

请注意,自 2012 年 12 月上旬以来,您可以直接从 GitHub创建新文件

Create new File

创建新文件

ProTip?: You can pre-fill the filename field using just the URL.
Typing ?filename=yournewfile.txtat the end of the URL will pre-fill the filename field with the name yournewfile.txt.

专家提示?:您可以仅使用 URL 预填充文件名字段。在 URL 末尾
键入?filename=yournewfile.txt将使用 name 预填充文件名字段yournewfile.txt

d

d

回答by Eyal Sooliman

You can use Git GUI on Windows, see instructions:

您可以在 Windows 上使用 Git GUI,请参阅说明:

  1. Open the Git Gui (After installing the Git on your computer).
  1. 打开 Git Gui(在您的计算机上安装 Git 后)。

enter image description here

在此处输入图片说明

  1. Clone your repository to your local hard drive:
  1. 将您的存储库克隆到本地硬盘:

enter image description here

在此处输入图片说明

  1. After cloning, GUI opens, choose: "Rescan" for changes that you made:
  1. 克隆后,GUI 打开,选择:“重新扫描”您所做的更改:

enter image description here

在此处输入图片说明

  1. You will notice the scanned files:
  1. 您会注意到扫描的文件:

enter image description here

在此处输入图片说明

  1. Click on "Stage Changed":
  1. 点击“舞台改变”:

enter image description here

在此处输入图片说明

  1. Approve and click "Commit":
  1. 批准并点击“提交”:

enter image description here

在此处输入图片说明

  1. Click on "Push":
  1. 点击“推送”:

enter image description here

在此处输入图片说明

  1. Click on "Push":
  1. 点击“推送”:

enter image description here

在此处输入图片说明

  1. Wait for the files to upload to git:
  1. 等待文件上传到 git:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

回答by astronautlevel

Open github app. Then, add the Folder of files into the github repo file onto your computer (You WILL need to copy the repo onto your computer. Most repo files are located in the following directory: C:\Users\USERNAME\Documents\GitHub\REPONAME) Then, in the github app, check our your repo. You can easily commit from there.

打开 github 应用程序。然后,将文件文件夹添加到您计算机上的 github 存储库文件中(您需要将存储库复制到您的计算机上。大多数存储库文件位于以下目录中:C:\Users\USERNAME\Documents\GitHub\REPONAME)然后,在 github 应用程序中,检查我们的 repo。您可以轻松地从那里提交。