git remote add origin gitee仓库地址> git push origin master //提交到远程仓库> git pull origin master //拉取到本地_git本地新建文件夹无法提交到仓库?">
赞
踩
> git init
> git add * //(*号表示提交本目录的全部文件,也可以提交某个文件)
> git add .gitignore //可以不写
> git commit -m "初始化提交"
> git remote add origin gitee仓库地址
> git push origin master //提交到远程仓库
> git pull origin master //拉取到本地
初始化:
查看状态、提交:
添加提交该文件的描述内容:
添加提交地址:
提交:
可能出现的问题:
问题(1)输入 $ git push -u origin master
出现以下问题:
To https://gitee.com/littlexiaoxiao/my_accumulate_code.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘https://gitee.com/littlexiaoxiao/my_accumulate_code.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
解决方法:git pull origin master --allow-unrelated-histories
再重新做一遍 add和commit,get…
问题(2)输入
git remote add origin https://gitee.com/(github/码云账号)/(github/码云项目名).git
出现 fatal: remote origin already exists.
翻译过来就是:致命:远程来源已经存在。此时,我们可以先 git remote -v 查看远程库信息:可以看到,本地库已经关联了origin的远程库,并且,该远程库指向GitHub。
解决办法:先删除关联,再重新添加提交地址,然后提交。
先输入$ git remote rm origin
(删除关联的origin的远程库)
再输入$ git remote add origin git@github.com:(github名)/(git项目名).git
就不会报错了!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。