git提交项目到已有库

借鉴地址:https://blog.csdn.net/jerryhanjj/article/details/72777618

Git global setup
git config --global user.name "张衍涛"
git config --global user.email "[email protected]"
Create a new repository
git clone http://192.168.1.202:8060/guodun-online/online.git
cd online
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

 上传项目

跟踪项目文件夹中的所有文件和文件夹

git add . 

输入本次的提交说明,准备提交暂存区中的更改的已跟踪文件,单引号内为说明内容

git commit -m 'first_commit'

关联远程仓库,添加后,远程库的名字就是 origin,这是 Git 默认的叫法,也可以改成别的,但是 origin 这个名字一看就知道是远程库。

git remote add origin https:xxxx.git

如果关联出现错误 fatal: remote origin already exists,则执行下列语句再进行关联

git remote rm origin

把本地库的所有内容推送到远程库上

git push -u origin master

如果在推送时出现错误 error:failed to push som refs to.......,则执行下列语句

git pull origin master

将远程仓库 Github 上的文件拉下来合并之后重新推送上去

执行最后一个语句仍然报错:

fatal: refusing to merge unrelated histories

通过以下语句修复(可能是新版git的问题):

git pull origin master --allow-unrelated-histories

猜你喜欢

转载自www.cnblogs.com/of-course/p/11577318.html
今日推荐