GitHub的使用小记

93 阅读1分钟

基本使用

配置查询命令

git config --list

初始化本地库

echo "# DEMO" >> README.md
git init
git add README.md
git commit -m "first commit"

查看本地配置库版本

git status

推送到远程服务器

git push

git 添加 .gitignore

git rm -r --cached .
git add .
git commit -m "add gitignore"
git push origin master

git push错误failed to push some refs to的解决

这个问题是因为远程库与本地库不一致造成的,那么我们把远程库同步到本地库就可以了。
使用指令

git pull --rebase origin master

这条指令的意思是把远程库中的更新合并到本地库中,–rebase的作用是取消掉本地库中刚刚的commit并把他们接到更新后的版本库之中。