从github上pull一个本地不存在的分支的方法?
ringa_lee
ringa_lee 2017-04-24 09:11:39
0
3
525

github分支结构

  • master
  • develop

本地代码的结构

  • master

现在我想从github中pull其develop分支,想达到本地也有master和develop分支的效果,但是我用

git pull origin develop

发现这条命令的结果是在本地的master分支基础上对github的develop分支进行合并

问题1:难道需要现在本地创建一个develop分支,然后checkout到本地develop分支,然后再执行git pull操作吗?如果是这样,那么如果本地分支的个数和github上相差很大时,需要每个都按照上面的方法走一遍?

问题2:有没有一条命令,能对本地的所有分支进行更新同步到github上面的版本?

问题3:有没有方法,能把所有的github的分支更新pull下来?

问题4:如果是本地存在某个分支test,而github上面不存在该分支,是不是需要人工删除?有没有像问题3中把所有分支更新pull下来,包括已删除的分支pull到本地之后,本地的相应分支也会删除

ringa_lee
ringa_lee

ringa_lee

reply all(3)
左手右手慢动作
  1. Correspondence of git fetch origin 取远程的变更即可。或者 git pull 取当前分支的更新的同时会把其它分支也拖回来的。除非 clone 的时候用了 -b 选项。你也可以用 git fetch origin develop 来指定。git fetchgit push.
  2. You are too lazy. man git-push You can see the answer (well, even though I didn’t know it before):

--all
Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.

阿神
  • If you only want to synchronize the remote repository to the local one:
$ git fetch origin
  • If you want to pull down certain content in the remote branch after completing the synchronization of the remote repository. Think about it carefully, git pull就是分为git fetchgit mergeIt is implemented by two commands, the former operates the repository, and the latter affects local files through the repository. Well, you can
$ git checkout -b localbranch
$ git pull origin remotebranch:localbranch // 当本地分支和远程分支名称相同时,只写一个就可以
// 这种方法适合pull指定分支
  • You need to push all local branches to the remote end
$ git push -all
伊谢尔伦

Understand git pull = fetch + merge, then question 3 cannot be done, because merge may have conflicts and can only operate one branch.

I also hate English manuals, they are hard to read. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template