//首先看一下自己是否有公钥,在 我的资料-->SSH公钥 查看,如果没有,添加自己的SSH 公钥:
//SSH Key 可以让你在你的电脑和 Git @ OSC 之间建立安全的加密连接
$ ssh -T git@git.oschina.net
//若返回
Welcome to Git@OSC, zb_j!
//则说明添加SSH公钥成功
boyatekiMacBook-Pro-2:~ zbj$ cd /Users/zbj/项目/osChina/weibo/Weibo
boyatekiMacBook-Pro-2:Weibo zbj$ git init
Initialized empty Git repository in /Users/zbj/项目/osChina/weibo/Weibo/.git/
boyatekiMacBook-Pro-2:Weibo zbj$ git init .
Reinitialized existing Git repository in /Users/zbj/项目/osChina/weibo/Weibo/.git/
boyatekiMacBook-Pro-2:Weibo zbj$ cd /Users/zbj/项目/osChina
boyatekiMacBook-Pro-2:osChina zbj$ git pull git@git.oschina.net:zbsourcecode/weibo.git
fatal: Not a git repository (or any of the parent directories): .git
boyatekiMacBook-Pro-2:osChina zbj$ git init .
Initialized empty Git repository in /Users/zbj/项目/osChina/.git/
boyatekiMacBook-Pro-2:osChina zbj$ git pull git@git.oschina.net:zbsourcecode/weibo.git
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From git.oschina.net:zbsourcecode/weibo
* branch HEAD -> FETCH_HEAD
boyatekiMacBook-Pro-2:osChina zbj$ git add -A .
boyatekiMacBook-Pro-2:osChina zbj$ git commit -am "第一次提交远程代码"
On branch master
nothing to commit, working directory clean
boyatekiMacBook-Pro-2:osChina zbj$ git add -A Weibo/.
boyatekiMacBook-Pro-2:osChina zbj$ git commit -am "第一次提交远程代码"
On branch master
Untracked files:
Weibo.textClipping
nothing added to commit but untracked files present
boyatekiMacBook-Pro-2:osChina zbj$ git rm Weibo.textClipping
fatal: pathspec 'Weibo.textClipping' did not match any files
boyatekiMacBook-Pro-2:osChina zbj$ git commit -am "第一次提交远程代码"
On branch master
nothing to commit, working directory clean
boyatekiMacBook-Pro-2:osChina zbj$ git status
On branch master
nothing to commit, working directory clean
boyatekiMacBook-Pro-2:osChina zbj$ git commit -m "第一次提交远程代码"
On branch master
nothing to commit, working directory clean
boyatekiMacBook-Pro-2:osChina zbj$ cd Weibo
boyatekiMacBook-Pro-2:Weibo zbj$ git add .
Assertion
failed: (item->nowildcard_len <= item->len &&
item->prefix <= item->len), function prefix_pathspec, file
pathspec.c, line 317.
Abort trap: 6
boyatekiMacBook-Pro-2:Weibo zbj$ cd /Users/zbj/项目/osChina
boyatekiMacBook-Pro-2:osChina zbj$ git add Weibo/
fatal: Unable to create '/Users/zbj/项目/osChina/.git/index.lock': File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
boyatekiMacBook-Pro-2:osChina zbj$ git add Weibo/.
fatal: Unable to create '/Users/zbj/项目/osChina/.git/index.lock': File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
boyatekiMacBook-Pro-2:osChina zbj$ cd /Users/zbj/项目/osChina
boyatekiMacBook-Pro-2:osChina zbj$ git init
Initialized empty Git repository in /Users/zbj/项目/osChina/.git/
boyatekiMacBook-Pro-2:osChina zbj$ git remote add origin git@git.oschina.net:zbsourcecode/weibo.git
boyatekiMacBook-Pro-2:osChina zbj$ git add .
boyatekiMacBook-Pro-2:osChina zbj$ git commit -a -m "第一次提交"
[master (root-commit) b2bf26b] 第一次提交
441 files changed, 24645 insertions(+)
create mode 100644 Weibo.xcodeproj/project.pbxproj
............................................................
create mode 100644 WeiboTests/WeiboTests.m
boyatekiMacBook-Pro-2:osChina zbj$ git pull origin master
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From git.oschina.net:zbsourcecode/weibo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Adding Weibo/main.m
................................................
Adding Weibo/Base.lproj/LaunchScreen.xib
CONFLICT
(directory/file): There is a directory with name Weibo in HEAD. Adding
Weibo as Weibo~3b0a93b55a67db54b9797b66856335c9fffe04c4
Automatic merge failed; fix conflicts and then commit the result.
boyatekiMacBook-Pro-2:osChina zbj$ open .
boyatekiMacBook-Pro-2:osChina zbj$ cd /Users/zbj/项目/osChina/weibo
boyatekiMacBook-Pro-2:weibo zbj$ git init
Initialized empty Git repository in /Users/zbj/项目/osChina/weibo/.git/
boyatekiMacBook-Pro-2:weibo zbj$ git remote add orgin git@git.oschina.net:zbsourcecode/weibo.git
boyatekiMacBook-Pro-2:weibo zbj$ git add .
boyatekiMacBook-Pro-2:weibo zbj$ git commit -a -m "第一次初始化"
On branch master
Initial commit
nothing to commit
boyatekiMacBook-Pro-2:weibo zbj$ git pull origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
boyatekiMacBook-Pro-2:weibo zbj$ open .
boyatekiMacBook-Pro-2:weibo zbj$ git add .
boyatekiMacBook-Pro-2:weibo zbj$ git commit -a -m "第一次初始化"
[master (root-commit) 4050f49] 第一次初始化
441 files changed, 24645 insertions(+)
create mode 100644 Weibo/Weibo.xcodeproj/project.pbxproj
............................................................
create mode 100644 Weibo/WeiboTests/WeiboTests.m
boyatekiMacBook-Pro-2:weibo zbj$ git pull origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
boyatekiMacBook-Pro-2:weibo zbj$ open push orgin master
The
files /Users/zbj/项目/osChina/weibo/push,
/Users/zbj/项目/osChina/weibo/orgin, and
/Users/zbj/项目/osChina/weibo/master do not exist.
boyatekiMacBook-Pro-2:weibo zbj$ git push origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
boyatekiMacBook-Pro-2:weibo zbj$ clear
boyatekiMacBook-Pro-2:weibo zbj$ git config --global user.name "zb_j"
boyatekiMacBook-Pro-2:weibo zbj$ git config --global user.email "1357316621@qq.com"
boyatekiMacBook-Pro-2:weibo zbj$ git init
Initialized empty Git repository in /Users/zbj/项目/osChina/weibo/.git/
boyatekiMacBook-Pro-2:weibo zbj$ touch README.md
boyatekiMacBook-Pro-2:weibo zbj$ git add README.md
boyatekiMacBook-Pro-2:weibo zbj$ git commit -m "first commit"
[master (root-commit) 46f1533] first commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
boyatekiMacBook-Pro-2:weibo zbj$ git remote add origin https://git.oschina.net/zbsourcecode/weibo.git
boyatekiMacBook-Pro-2:weibo zbj$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/zbsourcecode/weibo.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
boyatekiMacBook-Pro-2:weibo zbj$ cd /Users/zbj/Desktop/Weibo
boyatekiMacBook-Pro-2:Weibo zbj$ git remote add origin https://git.oschina.net/zbsourcecode/weibo.git
fatal: Not a git repository (or any of the parent directories): .git
boyatekiMacBook-Pro-2:Weibo zbj$ open .
boyatekiMacBook-Pro-2:Weibo zbj$ cd /Users/zbj/项目/osChina/weibo
boyatekiMacBook-Pro-2:weibo zbj$ git add .
boyatekiMacBook-Pro-2:weibo zbj$ git add ./
boyatekiMacBook-Pro-2:weibo zbj$ git commit -m "添加已有的项目"
[master 2364694] 添加已有的项目
441 files changed, 24645 insertions(+)
create mode 100644 Weibo/Weibo.xcodeproj/project.pbxproj
................................................
create mode 100644 Weibo/WeiboTests/WeiboTests.m
boyatekiMacBook-Pro-2:weibo zbj$ git remote add origin https://git.oschina.net/zbsourcecode/weibo.git
fatal: remote origin already exists.
boyatekiMacBook-Pro-2:weibo zbj$ git push -u origin master
Counting objects: 600, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (592/592), done.
Writing objects: 100% (599/599), 1.78 MiB | 12.00 KiB/s, done.
Total 599 (delta 159), reused 0 (delta 0)
To https://git.oschina.net/zbsourcecode/weibo.git
46f1533..2364694 master -> master
Branch master set up to track remote branch master from origin.
boyatekiMacBook-Pro-2:weibo zbj$
至此,提交成功