【问题标题】:Add project files from Local machine to Github Repository将项目文件从本地机器添加到 Github 存储库
【发布时间】:2016-01-13 08:49:16
【问题描述】:

我正在开发一个 iOS 项目。我们的员工创建了一个存储库说应用程序,默认情况下我们有一个主分支。员工创建了另一个分支,说“第二”现在我需要将我的项目文件从我的机器上传到 Github 存储库的“第二”分支,查看了很多教程,但不明白什么以及如何做到这一点......这个问题可能已经问过了,但抱歉没有帮助...

【问题讨论】:

  • git clone <url> --branch <branch> --single-branch [<folder>] 克隆一个特定的分支,然后像往常一样修改和提交,更改只会存在于您克隆的分支上。文档:git-scm.com/book/en/v2/…
  • 你能更好地描述一下吗,如果分支“second”是从你的 master 分支创建的,那么你只需要将“master”合并到“second”中。
  • @Krzysztof 我真的不太了解这些操作。这是我第一次使用 Github。但是当我问我的员工时,他说它是从 master 创建的
  • @Joker 如果我理解正确,那么您只需要切换到您的客户创建的分支并合并您的所有更改。但是你确定它不是新的存储库吗?如果你先做一些快速的 git 教程,那将是值得的。还有一些不错的 gui 客户端,例如源代码树,可能对您有所帮助。
  • @Krzysztof 是的,它不是一个存储库,它是一个分支。

标签: ios github repository branch


【解决方案1】:

首先,对您的项目进行完整备份,所以 如果出现问题,您可以恢复它。

如果你有本地 git 存储库(在终端中你可以在项目目录中执行“ls -la”命令后看到 .git 和 .git**** 文件):

1) Open your project folder with your local git repository in Terminal and add your Github repository as origin:
$ git remote add origin https://github.com/your_user/your_repo.git 
(This url you can see at Github repo) 

2) Push all your local branches onto repository:
$ git push --all origin

如果你没有本地 git 仓库:

1) Create new folder, go inside it and in Terminal execute this:
$ git clone https://github.com/your_user/your_repo.git

2) Copy all your iOS project (with inner files/folders/etc) into that folder

3) Add all your local files into local git repo:
$ git add .

4) Commit all changes:
$ git commit -m initial    

5) Push all your local branches onto repository:
$ git push --all origin

Also see Github help: 
https://help.github.com/articles/adding-a-remote/
https://help.github.com/articles/pushing-to-a-remote/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-23
    • 1970-01-01
    • 2013-01-04
    • 2018-08-28
    • 1970-01-01
    • 2020-05-12
    • 1970-01-01
    • 2017-11-24
    相关资源
    最近更新 更多