在本地分支没有远分支的情况下把远程分支拉到本地

在本地分支没有远分支的情况下把远程分支拉到本地:

1
2
3
4
5
6
git fetch origin branchname:branchname
可以把远程某各分支拉取到本地的branchname下,如果没有branchname,则会在本地新建branchname

git checkout -b localName origin/remoteName
获取远程分支remoteName 到本地新分支localName,并跳到localName分支
- {develop : 就是远程分支的名字}
1
2
git push origin develop
把代码提交到远程分支develop中
1
2
git rm -f 文件名
在提交前删除已经 add 好的文件
1
2
在develop上合并master后要这么推送一次,但是不知道为什么在master上合并develop却不需要推送
git push -u origin develop

本地没有显示远程分支的时候且拉取不到远程分支的时候 (git fetch)一下即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master

$ git checkout -b develop origin/develop
fatal: Cannot update paths and switch to branch 'develop' at the same time.
Did you intend to checkout 'origin/develop' which can not be resolved as commit?

$ git fetch
From gitlab.adxmai.com:sdk/MaiAPP
* [new branch] develop -> origin/develop

$ git branch -va
* master c8a503b 修改关闭按钮为tv,开屏不自动消失
remotes/origin/HEAD -> origin/master
remotes/origin/develop c8a503b 修改关闭按钮为tv,开屏不自动消失

Peace