配置ssh key(已配置请忽略):
1、查看.ssh
文件夹,没有则创建: mkdir ~/.ssh
2、切换目录:cd ~/.ssh
3、生成:ssh-keygen -t rsa -C "[email protected]"
4、 连续回车3次
5、查看公钥: cat id_rsa.pub
6、复制公钥:pbcopy
1、在http://git.oschina.net创建一个空项目,其中包含GitIgnore和readme文件
2、创建本地项目
3、cd进入本地项目目录,执行命令
yuanzhiyingdeMacBook-Pro:code yuanzhiying$ cd PictureBook/
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ ls
PictureBook PictureBookTests
PictureBook.xcodeproj PictureBookUITests
4、初始化本地git库
git init
git add .
git commit -m "first commit"
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git init
Initialized empty Git repository in /Users/yuanzhiying/code/PictureBook/.git/
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git add .
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git commit -m "first commit"
[master (root-commit) 5a48875] first commit
18 files changed, 1061 insertions(+)
create mode 100644 PictureBook.xcodeproj/project.pbxproj
create mode 100644 PictureBook.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create mode 100644 PictureBook.xcodeproj/project.xcworkspace/xcuserdata/yuanzhiying.xcuserdatad/UserInterfaceState.xcuserstate
create mode 100644 PictureBook.xcodeproj/xcuserdata/yuanzhiying.xcuserdatad/xcschemes/PictureBook.xcscheme
create mode 100644 PictureBook.xcodeproj/xcuserdata/yuanzhiying.xcuserdatad/xcschemes/xcschememanagement.plist
create mode 100644 PictureBook/AppDelegate.h
create mode 100644 PictureBook/AppDelegate.m
create mode 100644 PictureBook/Assets.xcassets/AppIcon.appiconset/Contents.json
create mode 100644 PictureBook/Base.lproj/LaunchScreen.storyboard
create mode 100644 PictureBook/Base.lproj/Main.storyboard
create mode 100644 PictureBook/Info.plist
create mode 100644 PictureBook/ViewController.h
create mode 100644 PictureBook/ViewController.m
create mode 100644 PictureBook/main.m
create mode 100644 PictureBookTests/Info.plist
create mode 100644 PictureBookTests/PictureBookTests.m
create mode 100644 PictureBookUITests/Info.plist
create mode 100644 PictureBookUITests/PictureBookUITests.m
5、复制项目地址,执行命令:
git remote add origin [email protected]:yuanzhiying/PictureBook.git
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git remote add origin [email protected]:yuanzhiying/PictureBook.git
6、拉取远程的代码
git pull origin master --allow-unrelated-histories
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git pull origin master --allow-unrelated-histories
From git.oschina.net:yuanzhiying/PictureBook
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
.gitignore | 20 ++++
LICENSE | 339 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 1 +
3 files changed, 360 insertions(+)
create mode 100644 .gitignore
create mode 100644 LICENSE
create mode 100644 README.md
7、进行分支绑定:
git branch --set-upstream-to=origin/master main
或
git branch --set-upstream-to=origin/master master
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git branch --set-upstream-to=origin/master master
Branch master set up to track remote branch master from origin.
8、本地代码推送到远程
git push origin main
或
git push origin master
yuanzhiyingdeMacBook-Pro:PictureBook yuanzhiying$ git push origin master
Counting objects: 34, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (34/34), 15.65 KiB | 0 bytes/s, done.
Total 34 (delta 4), reused 0 (delta 0)
To git.oschina.net:yuanzhiying/PictureBook.git
d598d61..42ab837 master -> master