输入“git remote add origin”提示fatal:remote origin already exists

做参考使用

1.因为本地的项目是别人从stash上git clone下来的,楼主今天推代码到远程仓库的时候,一直显示是别人的地址 

这里写图片描述

2.输入git init进行初始化

 这里写图片描述

3.然后又输入了git remote add origin 仓库地址,提示如下

4.输入“git remote rm origin”删除远程仓库

5.再输入git remote add origin 仓库地址,成功

6.输入git push origin,提示如图 
这里写图片描述

7.按照图中提示输入“ git push –set-upstream origin master”,输入用户密码,成功 
这里写图片描述

 

今天想把最近的一些代码push到码云上

先后运行:
git add .
git commit -m '一小段代码'
git remote add origin git@github.com:*****.git
在这一步git status发现一些顺利,于是继续执行:
git pull origin master
git push -u origin master
发现报错:
To https://gitee.com/WgLiux/Vuelearn.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://gitee.com/WgLiux/Vuelearn.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.
捣鼓半天又是撤销又是返回依然不行,明明pull过了,还提示git pull,想着是不是pull写错了,查资料后改成:
git pull --rebase origin master
然后再执行推送:
git push -u origin master
成功!

如果依然不行,可尝试git push -u origin master -f强制push

git clone error : malformed value for push.defaul:当前

在终端下载git代码时报错:

Cloning into 'Test'...

error: malformed value for push.default: 当前

error: Must be one of nothing, matching, simple, upstream or current.

fatal: bad config variable 'push.default' in file '/Users/Apple/.gitconfig' at line 21

 

解决方案:

1、打开终端,输入

git config --global push.default matching

2、再次执行clone或init就可以正常使用。

 

posted @ 2019-05-23 18:08  7411  阅读(1091)  评论(0)    收藏  举报