在本地初始化git仓库后,提交到远程分支。
先在git上初始化一个Repositories,记下地址。如果本地没有配置git的用户名和密码,那么就需要额外配置。请自行百度。
添加远程分支
# 添加
git remote add origin https://xxx.git
# 更改
git remote set-url origin http://gitlab.puhuitech.cn/wangli08/finup-hello-web.git
关联远程分支和本地分支,为了可以直接pull
git branch --set-upstream-to=origin/master master
git pull
//或者指定拉取的远程分支
git pull origin master
fatal: refusing to merge unrelated histories
因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在 git pull
之后,这句代码是在git 2.9.2版本发生的,最新的版本需要添加 --allow-unrelated-histories
告诉 git 允许不相关历史合并
git pull --allow-unrelated-histories
git push
官方方法:
git remote add origin https://github.com/Cribug8080/wl-tools.git
git push -u origin master
push之前确定已经commit文件。