remote tracking branches
来源:互联网 发布:三门会计软件下载 编辑:程序博客网 时间:2024/05/16 13:57
Confused about what exactly a remote tracking branch is? Don’t worry, it’s not just you. Basically, there’s two types of branches: local, and remote-tracking. Local branches are pretty run of the mill, they’re just another path in the DAG that you can commit to. Remote-tracking branches have a few different purposes:
- They’re used to link what you’re working on locally compared to what’s on the remote.
- They will automatically know what remote branch to get changes from when you use
git pull
orgit fetch
. - Even better,
git status
will recognize him how many commits you are in front of the remote version of the branch.
Luckily, the git branch
command gives us some insight to what branch is what. For most normal, freshly cloned repositories, you’ll see this output:
This just shows the default local branch, the master branch. If you wanted to see remote branches:
And finally, if you wanted to see them all:
When branches are created using the --track
option, they will be set up to linked to the remote branch. For example, if you wanted to create a new branch from the master branch from the origin remote, using this would set it up so it would pull from the remote and branch automatically:
From here you can git checkout
the branch and work with it, and since it’s tracking the remote branch, it will know where to bring in changes from when you fetch or pull.
Local branches can also be created from any start point, be it a remote tracking branch or any treeish passed in. Here are some examples:
Now, in these examples the --no-track
option was specified. This was done to ensure that the branches did not derive from a remote tracking branch. You can tweak how this works through your ~/.gitconfig
file. As the Git Cheat Sheet says:
git config branch.autosetupmerge true
tells git-branch and git-checkout to setup new branches so that git-pull(1)
will appropriately merge from that remote branch. Recommended. Without this,
you will have to add —track to your branch command or manually merge remote
tracking branches with “fetch” and then “merge”.
Hopefully this post has cleared up some confusion you may have had regarding branches and what exactly remote-tracking does. If you have more ideas on how to explain this better or related resources let us know in the comments or submit a tip!
http://gitready.com/beginner/2009/03/09/remote-tracking-branches.html
- remote tracking branches
- “Tracking Branches” And “Remote-Tracking Branches”
- “Tracking Branches” And “Remote-Tracking Branches”
- git里Remote Tracking Branches与Tracking Branches
- git delete remote branches
- Adding And Removing Remote Branches
- Track all remote git branches as local branches
- git push and delete remote branches
- clone & push all remote branches with git
- clone & push all remote branches with git
- Delete multiple git remote branches by prefixing colon
- how to clone all remote branches in git
- git远程删除分支后,本地remote tracking还有
- Moving git repository and all its branches, tags to a new remote repository keeping commits history
- Tracking
- Tracking
- svn trunk/branches/tag
- trunk, branches, tags
- 【HUSTOJ】1041: 阿姆斯特朗数
- Myeclipse中java项目转成Web项目
- MAC OSX下用pip无法安装lxml的解决办法
- ipvsadm 命令参考
- 【VS开发】PCIe体系结构的组成部件
- remote tracking branches
- 详解OJ(Online Judge)中PHP代码的提交方法及要点【举例:ZOJ 1001 (A + B Problem)】
- Android Orm框架分析
- C++基础实例-类(7)
- Java实现-----问题和对应答案的添加和删除(前台和后台)
- java 的序列化和反序列化的概念及简单使用
- POJ 2376- Cleaning Shifts(贪心)
- bzoj 1455: 罗马游戏(可并堆)
- socket中read、write、send、recv函数的比较