程序员的资源宝库

网站首页 > gitee 正文

git 提交本地项目到码云 git上传到码云

sanyeah 2024-03-29 14:50:09 gitee 4 ℃ 0 评论

首先在码云上面新建一个项目。

在新建项目时 选择不添加README.md文件(重要)

 

然后,进行如下操作:

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 -A //添加所有文件

 

6. git commit -a -m  "注释内容” //添加注释

 

7. git remote add origin https://git.oschina.net/username/xxx.git(你的远程仓库地址,即是码云的项目路径)     //和远程仓库进行关联

如果报错:fatal: remote origin already exists.

 解决方法:

 

 1、先输入$ git remote rm origin

 

    2、再输入$ git remote add origin git@github.com:djqiang/gitdemo.git 就不会报错了!

 

    3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容

 

    4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

 

    5、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!

 

 

8. git push origin master //上传仓库到码云

如果报错: failed to push some refs to 'git@github.com:

可能原因: 

GitHub远程仓库中的README.md文件不在本地仓库中。


解决方案:

git pull --rebase origin master   #拉取合并代码
git push -u origin master         #上传仓库到码云    

 

 

 
补充一个可能遇到的警告:
[plain] view plain copy
 
  1. warning: LF will be replaced by CRLF in ......      
  2. The file will have its original line endings in your working directory.     

解决方法:
git config --global core.autocrlf false
就可以解决了。

原因是路径中存在 / 的符号转义问题,false就是不转换符号。
而默认是true,相当于把路径的 / 符号进行转义,这样添加的时候就有问题

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表