第一次提交本地代码到远程分支
- git init
- git remote add origin [url]
- git pull origin master –allow-unrelated-histories
- git add .
- git commit -m ‘解释说明文字’
- git push oriign master
出现的问题fatal: refusing to merge unrelated histories 解决问题:git pull origin master –allow-unrelated-histories
创建本地分支提交到远程
- git branch dev
- git checkout dev
- git add .
- git commit -m ‘解释说明文字’
- git push origin dev
创建并切换分支:git checkout -b mybranch
拉取远程分支到本地
- git branch -r 查看远程分支
- git fetch origin 远程分支名x:本地分支名x(方法1)
- git checkout -b 本地分支名x origin/远程分支名x(方法2)
更改git仓库地址
命令行修改
- git remote rm origin
- git remote add origin [url]