这是我总结运用过的一些git指令,name为分支名,如有不对,请提出,谢谢。
- 仓库初始化
git init
- 检验本地内存文件
git status
- 加载入本地内存
git add .
- 命名文件内存
git commit -m 'name'
- 首次添加根目录入远程仓库
git push -u origin name
- 更换分支
git checkout name
- 显示分支
git branch
- 合并分支
git merge name
- 补充进远程仓库
git push
- 创建新分支
git checkout -b name
- 查看本地和远程所有分支
git branch -a
- 查看远程仓库的分支
git branch -r
- 将本地分支和远程分支同步
git checkout -r 本地name origin/远程name
- 删除远程分支
git push origin --delete name
- 删除本地分支
git branch -d name
- 同步所有远程分支
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
- 将本地所有分支与远程保持同步
git fetch --all
- 拉去所有分支代码
git pull --all
- 加入码云仓库
git remote add origin https链接
码云仓库建立后同步流程,给予仓库权限后按照步骤1、19、16即可,其中16需要在git bash后者powershell使用。
git init
git remote add origin https链接
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done