git的入门使用


在github新建一个仓库

此命令初始化一个新本地仓库
1.git init 目文件夹下面的文件都添加进来 2.git add .
提交说明 3.git commit
-m ''
让本地仓库和远程仓库建立连接
4.git remote add origin +  //远程仓库地址

把本地仓库push到github上面
5.git push origin master
如果push上去出现以下情况
$ git push origin master
To https://github.com/1769073060/Mybatis.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/1769073060/Mybatis.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.

解决办法

$ git pull --rebase origin master  --先把远程拉下来
$ git push origin master   --再提交本地就好了
 
 

# 显示所有远程仓库

$ git remote -v

原文地址:https://www.cnblogs.com/rzkwz/p/12423840.html