GIT 上传代码基本指令
一般分两种情况:
1.本地仓库与远程仓库未关联
// 代码上传环境初始化
git init // git 初始化命令,会创建本地仓库。
git status // 查看仓库状态。
// 将代码上传到本地仓库
git add .
git commit -m "更新内容说明"
// 拉取远程仓库代码
git remote add origin 远程仓库地址 // 将本地仓库与远程仓库关联。
git pull origin 远程分支名 --allow-unrelated-histories // 强行拉取,无视仓库关联性。
git push // 如果用用户名和密码方式还要追加 -u origin 分支名,不推荐。
// 如果想让本地仓库换关联,需要取消关联,解决报错:fatal: remote origin already exists.
git remote rm origin
2.本地仓库与远程仓库已关联
git clone 远程仓库地址
git add .
git commit -m "更新内容说明"
git pull // 推荐追加 --rebase
git push