最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[记录]Xcode中下载和上传来自OSChina的Git仓库的代码

Xcode crifan 4178浏览 0评论

OSChina的git仓库地址里面是空的,只有一个md文件:

oschina git only md file

 

需要把本地一个项目代码上传上去。

 

【折腾过程】

1.Xcode中去下载已有的代码

xcode source control check out git

 

protocol repostory project xcodeproj

输入git的地址:

input git repository url for ios

 

弹出让你输入用户名和密码的对话框:

address git type git user name and password

 

然后就是去验证权限:

verifying credentials for check out

 

一直下载不下来了。。。

 

然后后来从网页中拷贝出来的git地址是:

https://git.oschina.net/xxx/yyy.git

多了个后缀git

 

然后再去重新输入带git的地址,就可以了,可以正常下载代码了:

git check out ok loading branches

 

选择保存位置,然后即可开始下载:

show downloading note

 

下载完毕,即可自动打开Finder:

可以看到对应的

git隐藏文件夹

md文件

downloaded git project md file

 

接下来,想要把本地的项目源码,上传到这个远端的git仓库。

 

去尝试:

后来重新创建了一个iOS项目,然后保存的时候,加上git服务器:

https://git.oschina.net/xxx/yyy.git

enter a new git server address when create git xcode

 

registed user and name pwd add

 

结果半天无法连接上去。

 

算了,还是,保存到前面pull之后的远程git的本地的位置

 

然后本地把之前的项目的源码导入进来后,当前项目就有代码了:

import from existed jiandao project ios

 

然后再去:

先pull更新:

xcode soure control pull

由于git服务器上没有更新,所以此处提示:

The working copy  has uncommitted changes.

Commit or discard the changes and try again.

the working copy has uncommitted changes

(后来才知道,这个提示是:

本地有未提交的更新,所以没法从服务器pull更新

-》否则会冲掉本地的改动的)

 

再去试试push上传:

xcode push under source control

 

然后就可以提交了:

push local changes for origin master push

pushing changes for origin master

 

然后再去,网页中登陆git地址,看看是否有对应项目的代码了:

结果没有更新的代码

 

好像是缺少了commit,所以再去commit:

xcode source control commit

 

xcode commit push to remote origin master

 

The working copy “iOS-Client” failed to commit files.
error: pathspec 'JianDao/JianDao.xcodeproj/project.pbxproj' did not match any file(s) known to git.
error: pathspec 'JianDao/JianDao/Constants.swift' did not match any file(s) known to git.
error: pathspec 'JianDao/JianDao/Base.lproj/Main.storyboard' did not match any file(s) known to git.
error: pathspec 'JianDao/JianDao/Base.lproj/LaunchScreen.storyboard' did not match any file(s) known to git.
error: pathspec 'JianDao/JianDao/Info.plist' did not match any file(s) known to git.

如图:

the working copy failed to commit files

 

算了,再去重新试试Refresh Status:

refresh status xcode source control

 

算了:

抽空去命令行中上传代码吧。。。

此处:

pushing changes….

有点问题:

push到本地仓库,都一直无法成功push。。。

 

再去重新试了一遍:

删除当前项目

重新用Xcode去check out

新建项目保存到对应目录

最后xcode中pull,push,结果就一致无法push成功。。。

are you sure you want to cancel the operation

 

算了,退出xcode,去试试terminal中push:

[已解决]git 命令行方式去上传代码到远程到git服务器

 

是可以的。

但是结果回头用Xcode去push到本地,都还是出错。。。

那直接去commit到remote的origin master中去试试,最后好像成功了。。。

去网页中看看:

稍等片刻,即可看到最新的更新了。

oschina can show newly commited code

 

后来又有几次继续上传代码:

记得一定要:

push to remote

这样才能把本地代码上传到远程到git服务器上。

note to push to remote before commit

 

[总结]

此处的Xcode的push到本地,貌似是不行的。

然后Xcode中,直接去commit-》push to remote origin/master 结果commit也会失败

-》

最后是:

到mac的terminal用git命令行去commit:

[已解决]git 命令行方式去上传代码到远程到git服务器

之后,如果Xcode中有文件改动,再去通过Xcode中的:

commit-》push to remote origin/master

就可以正常上传代码了。

转载请注明:在路上 » [记录]Xcode中下载和上传来自OSChina的Git仓库的代码

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.164 seconds, using 22.11MB memory