首先要有码云的账号,并记住用户名和密码:
步骤:
1.cd 切换到工程目录
2.Git全局设置
git config --globaluser.name "user.name"
git config --global user.email "user.email"
3.git init //初始化一个git 仓库
4. touch README.md //创建帮助文件
5. git add README.md //添加文件
6. git commit -m "注释内容” // 添加注释
7. git remote add origin https://git.oschina.net/username/cccc.git 你的远程仓库地址 // 和远程仓库进行关联
8. git push -u origin master //上传仓库到码云
注意:刷新页面 后,如果是只上传了README文件,需要执行如下操作:
a. git add . //添加工程目录下所有文件 (add 和 “.” 之间有空格)
b. git commit -m “添加注释信息"
c. git push -u origin master //推送要上传的文件
可能遇到的问题:
在执行git push -u origin master时:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/olivermeng/octopus_purchase.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:
执行 git pull origin master
在Git pull时遇到:
fatal: refusing to merge unrelated histories
解决方法:
git pull origin master --allow-unrelated-histories
从新执行pull 然后再push 就可以了~