初始化
git init
添加远程云端地址
将本地仓库与云端(如GitHub、GitLab)的仓库关联
git remote add origin <远程仓库地址>
同步和关联远程分支。
同步远程分支
git pull origin master
将本地分支与远程分支关联
在首次拉取之后,你需要指定某个本地分支关联远程分支,下次提交会直接提到关联分支
git branch --set-upstream-to=origin/master master
设置不提交列表
通过根目录下的 .gitignore
文件设置不提交到云的文件列表
node_modules
dist
提交代码
一旦设置了追踪关系,以后你可以直接使用git pull来拉取并合并远程分支的更新到当前工作分支,或者使用git push来推送本地分支的更改到远程分支
git pull
git add .
git commit -m"注释"
git push