2.提交到远程仓库

将本地项目提交到远程仓库需要以下操作:

1. 本地提交

git init   初始化本地仓库
git add . 
git commit -m "###"      

2. 添加目标仓库地址

git remote add origin [email protected]:repos/xxx/xxx/xxx.git

3. 同步到远程仓库,先 pullpush

# 允许一些无关联的历史	
git pull origin master --allow-unrelated-histories      

git push origin 本地分支:远程分支

# 强制进行push
git push origin master -f  

修改远程仓库地址3种方式

1. 直接修改

2. 先删除后修改

删除

查看 remote url

git remote -v

3. 直接修改项目目录下.git 文件夹下config配置文件

常见问题

! [rejected] master -> master (fetch first) error: failed to push some refs to 'gitee.com:smallcgq/document.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

  • --force 强制提交到master分支

最后更新于

这有帮助吗?