markdown branch:创建,推送,跟踪分支

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown branch:创建,推送,跟踪分支相关的知识,希望对你有一定的参考价值。

**Create a new branch:**

`git checkout -b <new branch name>`

Push a new branch and track it immediately

When you create a new branch and push it to `origin`, you won’t be tracking it. This means a `git pull` won’t know its remote version.

You could use difficult commands to set up a branch’s tracking but it’s easier to just push it like this:
 
`git push -u`
  

From the [documentation on git push](http://linux.die.net/man/1/git-push):

`-u, --set-upstream`

*e.g.*

`git push origin --set-upstream <branch_name>`

*For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch..merge in git-config(1).*



---



**Set an existing branch to track a remote branch**

If you already have a local branch and want to set it to a remote branch you just pulled down, or want to change the upstream branch you’re tracking, you can use the `-u` or `--set-upstream-to` option to `git branch` to explicitly set it at any time.

`git branch -u origin/serverfix`

 Branch serverfix set up to track remote branch serverfix from origin.

以上是关于markdown branch:创建,推送,跟踪分支的主要内容,如果未能解决你的问题,请参考以下文章

Branch.io 跟踪没有奖励的推荐

Git怎么推送本地分支到远程新分支上面去

自定义子域设置后,Branch.io 链接不跟踪点击次数

git里面怎么看local branch和remote branch的关系

markdown 从CLI推送文本到创建的文件

排除 merge_request,在 gitlab CI 管道中推送创建作业