remote tracking branches
2016-05-05 13:50
267 查看
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
Even better,
remote version of the branch.
Luckily, the
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
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
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
that the branches did not derive from a remote tracking branch. You can tweak how this works through your
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
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 pullor
git fetch.
Even better,
git statuswill recognize him how many commits you are in front of the
remote version of the branch.
Luckily, the
git branchcommand gives us some insight to what branch is what. For most
normal, freshly cloned repositories, you’ll see this output:
$ git branch * master
This just shows the default local branch, the master branch. If you wanted to see remote branches:
$ git branch -r origin/HEAD origin/master
And finally, if you wanted to see them all:
$ git branch -a * master origin/HEAD origin/master
When branches are created using the
--trackoption, 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:
$ git branch --track feature1 origin/master Branch feature1 set up to track remote branch refs/remotes/origin/master.
From here you can
git checkoutthe 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:
$ git branch --no-track feature2 origin/master $ git branch --no-track feature3 HEAD~4 $ git branch --no-track feature4 f21e886
Now, in these examples the
--no-trackoption 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
~/.gitconfigfile.
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
相关文章推荐
- 【VS开发】PCIe体系结构的组成部件
- 【HUSTOJ】1041: 阿姆斯特朗数
- POJ 3050-Hopscotch(BFS)
- PerfMon Metrics Collector插件的Disks I/O使用总结
- iOS之修改项目BUG之旅--(二)
- ipvsadm 命令参考
- Myeclipse中java项目转成Web项目
- MAC OSX下用pip无法安装lxml的解决办法
- SHFileOperation()函数移动,复制,删除文件\文件夹
- 北京大学信息科学技术学院本科生课程体系课程大纲选摘-程序设计基础(大一上学期课程)
- linux centos 安装php的memcache扩展
- Concurrent包中ConcurrentHashMap
- SAP SD销售收入科目确定VKOA
- “Tracking Branches” And “Remote-Tracking Branches”
- 存储方式三 ------------------归档
- MYSQL必知必会读书笔记第八章之使用通配符进行过滤
- android开发系列之二—欢迎页面幻灯制作
- LVS-ipvsadm 实现负载均衡(以keepalive为基础)
- javascript笔记——placehold
- MySQL 修改表结构