当没有git仓库的时候
1. 初始化git仓库
git init
2. 提交暂缓区
git add .
3. 提交代码
git commit -m "first commit"
4. 添加仓库
git remote add origin 自己的仓库名
5. 推送主分支
git push -u origin "master"
当已有仓库
1. 添加仓库
git remote add origin 自己的仓库名
2. 推送主分支
git push -u origin "master"
创建分支
1. 查看当前的所有分支
git branch -a
2. 创建分支
git branch 分支名
3. 切换分支
git checkout 分支名
4. 推送分支到远程仓库并相关联
git push -u origin 分支名
删除分支
1. 查看分支
git branch -a
2. 切换到master分支
git checkout master
3. 删除本地分支
git branch -d 本地分支
4. 删除远程分支
git push origin --delete 远程分支