参考博客:http://www.cocoachina.com/ios/20161009/17698.html
2 开始建立本地库,在终端继续输入
1.cd到目标文件夹。
2.git init(在本机上想要创建一个新的git仓库)
3.git add -A (这里的-A是指将目标文件的所有文件都添加到git中,若不需要添加所有文件,可将-A换成具体的文件名)
4.git remote add origin xxxxxxxxx xxxxxx就是你仓库的地址
5.git commit -m “firstCommit” ("firstCommit" 也可以改成其他的说明性的文字,最终会显示在 github 界面 文件名的后边)
如下图红框所示
在第一次上传代码时 出现了以下情况:
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'crystal@crystal-Inspiron-5425.(none)')
这里是让你输入全局项目的 user.email 和 user.name.当然每个项目也可以设置局部的 user.email 和 user.name. 由于初步使用,故根据提示输入以下指令
git config --global user.email "*****@gmail.com"
git config --global user.name "crystal"
6.git pull --rebase origin master 更新远程更新到本地
推送本地更新到远程:
7.git push origin master(git push -u origin master) 将本地repo于远程的origin的repo合并,第一次用-u,系统要求输入账号密码
此时会出现
Username for 'https://github.com':
Password for 'https://[email protected]':
根据提示输入github帐号密码即可
8.git pull