git 新建仓库第一次提交

1 . git init //初始化仓库,在初始化的目录中会出现.git的文件

2. git add .(文件name) //添加文件到本地仓
 
3. git commit -m "first commit" //添加文件描述信息,越详细越好
 
4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
 
5. git push -u origin master //把本地仓库的master的文件推送到远程仓库
提交之后输入用户名密码后就会出现以下错误
To https://gitee.com/lulin-oldboy/devops.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'url'
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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

想解决以上错误,只需要在4,5之间使用git pull origin master即可

1. git init //初始化仓库
2. git add .(文件name) //添加文件到本地仓库
3. git commit -m "first commit" //添加文件描述信息越详细越好
4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
5. git pull origin master // 把本地仓库的变化连接到远程仓库主分支
6. git push -u origin master //把本地仓库的文件推送到远程仓库

 问题解决,可以正常使用git了

猜你喜欢

转载自www.cnblogs.com/lulin9501/p/11262275.html
今日推荐