Git代码提交操作,以及git push提示failed to push some refs"XXX"
1. 新建空文件夹,在git bash中执行以下命令,下拉git最新代码;
git clone https://xx,
若只是更新代码,则执行git pull 相当于将远程的代码下载到本地,与你本地的代码合并
git pull

2. 查看本地代码状态,是否有待提交的代码,红色字体显示的是修改过的文件(待提交)
git status

3. 提交代码至本地git缓存区:
根据提交的单个文件或全部文件,分为以下两种提交方式
1)git add . 将本地代码全部提交
2)git add xxx(红色文件链接)

4. 提交代码至本地git库:git commit -m "代码提交内容" 为本次提交添加注释
git commit -m "代码提交内容"

5.把git本地仓库的代码提交至远程主机的某个分支
- git push <远程主机名> <远程分支名>:
git push origin master
git push提示failed to push some refs"XXX"
推代码error,出现错误的原因是github中的README.md文件不在本地代码目录中。很明显,这是因为远程库与本地库不一致造成的,
也就是说我们需要先将远程代码库中的任何文件先pull到本地代码库中,才能push新的代码到github代码库中,接下来把远程库同步到本地就可以了
6.解决冲突:
git pull --rebase origin master
- 这条指令的意思是把远程仓库中的更新合并到本地库中,–rebase的作用是取消本地库中commit,并接到新版本库中,之后在 执行上面代码后可以看到本地代码库中多了README.md文件
7.将提交的代码推送到主分支
git push -u origin master
每天进步一小步 日积月累跨大步