git初始化项目提交到码云

1在码云新建项目

2本地新建项目,包括readme.md,ignore这俩个文件

初始化仓库

git init 

关联远程仓库

 

git remote add origin git@github.com:YotrolZ/helloTest.git
git add *
git commit —m"初次提交"
E:\mm\zdh>git push -u origin master------------我们第一次push的时候,加上-u参数,Git就会把本地的master分支和远程的master分支进行关联起来,我们以后的push操作就不再需要加上-u参数了
To https://gitee.com/antims/zdh.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/antims/zdh.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.


E:\mm\zdh>git pull origin master
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From https://gitee.com/antims/zdh
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories


E:\mm\zdh>git push -u origin master-------------------不可以
To https://gitee.com/antims/zdh.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/antims/zdh.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.


E:\mm\zdh>git push -u  -f origin master----------------------注释:-f是强制推送,覆盖远程
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 316 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To https://gitee.com/antims/zdh.git
 + b9d4e84...fb730f5 master -> master (forced update)
Branch master set up to track remote branch master from origin.

 

总计操作如下即可:

 

2本地新建项目,包括readme.md,ignore这俩个文件

初始化仓库

git init 

关联远程仓库

 

git remote add origin git@github.com:YotrolZ/helloTest.git
git add *
git commit —m"初次提交"
git pull origin master
git push -u  -f origin master

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值