美文网首页
上传项目到github

上传项目到github

作者: 妖妖零幺幺 | 来源:发表于2018-12-21 14:14 被阅读0次

    上传项目到github

    1、新建github仓库

    新建仓库

    2、建立git仓库

    git init
    

    3、将项目所有文件添加到仓库中

    git add .
    

    4、提交到仓库

    git commit -m "更新说明"
    

    5、将本地仓库关联到Github

    git remote add origin https://github.com/WHeB/EmptyView.git
    

    6、先拉取分支

    git pull origin master
    

    7、push到远程分支

    git push -u origin master
    

    更新github项目

    1、更新全部

    git add .
    

    2、提交更新

    git commit -m "更新说明"
    

    3、先拉取最新代码

    git pull
    

    4、push到远程仓库

    git push origin master
    

    制作cocoapods库(制作podspec文件)

    1、制作podspec文件

    pod spec create WPEmptyView
    

    2、编辑podspec文件

    • 命令行 vi FanRefresh.podspec
    • 直接打开文件编辑

    3、编辑文件内容

    Pod::Spec.new do |s|
    
      s.name         = "WPEmptyView"
      s.version      = "1.1"
      s.summary      = "为View添加空数据页面"
      s.description  = <<-DESC
                       为UIView增加空状态页面
                       DESC
      s.homepage     = "https://github.com/WHeB/EmptyView"
      s.license      = "MIT"
      s.author             = { "WHeB" => "1193325271@qq.com" }
      s.platform     = :ios, "9.0"
      s.swift_version = '4.0'
      s.source       = { :git => "https://github.com/WHeB/EmptyView.git", :tag => "#{s.version}" }
      s.source_files  = "WPEmptyView/*.swift"
      s.framework   = "UIKit"
    
    end
    
    

    4、创建tag,并提交更新到git仓库

    git add .
    git commit -m "version 1.1"
    git tag 1.1
    git push --tags
    git push origin master
    
    

    5、验证podspec文件

    pod spec lint WPEmptyView.podspec 
    或
    pod spec lint WPEmptyView.podspec --allow-warnings
    
    • 这一步会出现各种错误,只能一步步解决。

    6、

    pod trunk push WPEmpetView.podspec
    或
    pod trunk push WPEmpetView.podspec --allow-warnings
    

    7、成功

    完成.jpeg

    8、搜索

    pod search WPEmptyView
    

    为何找不到呢?

    • 刚提交后项目用pod search命令会搜不到,因为本地的索引没有更新。
    • 删除索引文件
    rm ~/Library/Caches/CocoaPods/search_index.json
    
    • 再重新搜索

    后记

    1、错误

    • error: failed to push some refs to 。。。
    error1

    原因:需要先把远程仓库和本地库合并
    解决方案:先拉下来(会自动合并)再上传

    git pull origin master 或 git pull --rebase origin master
    
    • rebase的作用是取消掉本地库中刚刚的commit,并把他们接到更新后的版本库之中。

    2、错误

    • [!] You need to register a session first.

    原因:第一次上传会遇到,github给您发邮件用的
    解决方案:

    pod trunk register 邮箱 '姓名'
    

    3、错误

    • ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.

      "Convert > To Current Swift Syntax…
    error3

    解决方案:指定swift版本

    • 在项目的 Build Settings -> Swifty Language Version中 指定swift版本
    • 在podspec文件中指定版本
    s.swift_version = '4.0'
    

    4、错误

    • ERROR | [iOS] file patterns: The source_files pattern did not match any file.
      原因:podspec中source_file配置错误
      解决方案:修改source_file路径
      source_files路径是相对于.podspec文件的文件路径。
      例:
      s.source_files = "WPEmptyView/*.swift"
      error4

    5、 git add . 或 git add *,git add -u,git add -A区别

    • git add . 或 git add *
      提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件
    • git add -u
      提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)
    • git add -A
      提交所有变化

    6、删除tag

    • 删除本地tag
      git tag -d 0.1
    • 删除远端tag
      git push origin :refs/tags/0.1

    相关文章

      网友评论

          本文标题:上传项目到github

          本文链接:https://www.haomeiwen.com/subject/kgiykqtx.html