git提交项目到远程仓库

git提交项目到远程仓库

操作记录

1.git项目创建

首先,先在git上面创建一个新的项目
在这里插入图片描述

2.项目提交

1、 初始化

git init

在这里插入图片描述

2、添加

git add . 

注意这里的add后面是有个点的,别漏了!!!而且中间要有空格

问题The file will have its original line endings in your working directory

原因:代码中存在LF换行符,在windows上,git会自动转换,所以
会提示相关的信息

解决: 关闭转换功能

git config core.autocrlf false    

3、 提交

git commit -m '提交'

4、 指向git路径

git remote add origin + 远程仓库地址

如果地址有添加过,需要切换成新的,则
删除旧的地址

git remote rm origin
git remote add origin 新的远程仓库地址

**5、**如果远程仓库有文件,则先pull拉取项目文件

git pullorigin master

6、 推送

git push origin master

问题 1atal: branch ‘master‘ does not exist
解决
1. git pull origin master --allow-unrelated-histories
2. git branch --set-upstream-to=origin/master master

问题 2Updates were rejected because the tip of your current branch is behind
解决:这是两端有不同文件导致的,直接强推就行
git push -u origin master -f

问题 3See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
解决:这是合并分支出现问题

没有设置默认分支
git pull origin master --allow-unrelated-histories
设置了默认分支
git pull --allow-unrelated-histories

问题 4Exiting because of an unresolved conflict
解决:这是代码中有出现冲突

查看冲突文件
git status

解决掉冲突的文件就好
然后,重新add、commit、pull、push

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值