mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-02 18:54:27 +02:00
parent
c029a5876f
commit
f0913d4e4c
16 changed files with 1197 additions and 7 deletions
|
@ -4,10 +4,12 @@ exports.level = {
|
|||
"startTree": "{\"branches\":{\"master\":{\"target\":\"C1\",\"id\":\"master\",\"remoteTrackingBranchID\":\"o/master\"},\"o/master\":{\"target\":\"C1\",\"id\":\"o/master\",\"remoteTrackingBranchID\":null}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"}},\"HEAD\":{\"target\":\"master\",\"id\":\"HEAD\"},\"originTree\":{\"branches\":{\"master\":{\"target\":\"C2\",\"id\":\"master\",\"remoteTrackingBranchID\":null}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"}},\"HEAD\":{\"target\":\"master\",\"id\":\"HEAD\"}}}",
|
||||
"name": {
|
||||
"en_US": "Remote Tracking",
|
||||
"zh_CN": "Remote Tracking",
|
||||
"de_DE": "Remote Tracking"
|
||||
},
|
||||
"hint": {
|
||||
"en_US": "Remember there are two ways to set remote tracking!",
|
||||
"zh_CN": "有两种设置无端跟踪的方法!",
|
||||
"de_DE": "Nicht vergessen, es gibt zwei Arten Remote Tracking einzurichten!"
|
||||
},
|
||||
"startDialog": {
|
||||
|
@ -129,6 +131,121 @@ exports.level = {
|
|||
}
|
||||
]
|
||||
},
|
||||
"zh_CN":{
|
||||
"childViews": [
|
||||
{
|
||||
"type": "ModalAlert",
|
||||
"options": {
|
||||
"markdowns": [
|
||||
"### Remote-Tracking branches",
|
||||
"",
|
||||
"在前几节课程中有件事儿挺神奇的, git 好像知道`master`与`o/master`是相关的. 当然, 这些分支的名字是相同的, 所以可能是这种逻辑连接了远端的master分支和本地的master分支, 其实这种连接在以下两种情况下清楚体现: ",
|
||||
"",
|
||||
"* pull操作时, 我们下载提交到o/master并且合并到本地master分支。隐含的合并目标由此连接确定.",
|
||||
"* push操作时, 我们把工作从`master`推到远端的`master`(同时会更新远端的副本`o/master`) 这个推送的目的地也是由这种连接确定的! ",
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ModalAlert",
|
||||
"options": {
|
||||
"markdowns": [
|
||||
"## 远端跟踪",
|
||||
"",
|
||||
"长话短说, `master` 和 `o/master` 的连接关系就是 分支属性\"remote tracking\" (我们叫远端跟踪好啦). `master` 被设定为跟踪 `o/master` -- 这就是隐含的合并(merge)/推送(push)目的地.",
|
||||
"",
|
||||
"你可以想知道这个属性是怎么被设定的? 你并没有用命令指定过这个属性呀! 好吧, 当你克隆仓库的时候, 这个属性就存在了. ",
|
||||
"",
|
||||
"当你克隆时, git会创建跟踪分支(就像`o/master`), 对于每个远端分支, 创建一个跟踪远端分支的本地分支(`master`), 所以你经常会看到这个的命令输出:",
|
||||
"",
|
||||
" local branch \"master\" set to track remote branch \"o/master\"",
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ModalAlert",
|
||||
"options": {
|
||||
"markdowns": [
|
||||
"### 我能自己指定这个属性吗?",
|
||||
"",
|
||||
"当然可以啦! 你可以让做生意分支跟踪`o/master`, 然后分支就会隐含push的destination(`o/master`) 以及merge的target (`o/master`). 这意味着你可以在分支`totalllyNotMaster`上执行`git push`, 将工作推送到远端的`master`.",
|
||||
"",
|
||||
"有两种方法设置这个属性, 第一种就是通过远端分支检出一个新的分支, 执行: ",
|
||||
"",
|
||||
"`git checkout -b totallyNotMaster o/master`",
|
||||
"",
|
||||
"这样就创建了一个跟踪 `o/master` 的 新分支`totallyNotMaster`. "
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "GitDemonstrationView",
|
||||
"options": {
|
||||
"beforeMarkdowns": [
|
||||
"说得够多了, 我们看看演示! 我们检出一个名叫`foo`的新分支, 然后让其跟踪远端的`master`."
|
||||
],
|
||||
"afterMarkdowns": [
|
||||
"正如你所看到的, 我们使用了隐含的目标`o/master`来更新`foo`分支. 注意, master未被更新!"
|
||||
],
|
||||
"command": "git checkout -b foo o/master; git pull",
|
||||
"beforeCommand": "git clone; git fakeTeamwork"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "GitDemonstrationView",
|
||||
"options": {
|
||||
"beforeMarkdowns": [
|
||||
"git push 同样适用这一原则"
|
||||
],
|
||||
"afterMarkdowns": [
|
||||
"我们将一个不叫`master`的分支工作 推送到的远端的`master`."
|
||||
],
|
||||
"command": "git checkout -b foo o/master; git commit; git push",
|
||||
"beforeCommand": "git clone"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ModalAlert",
|
||||
"options": {
|
||||
"markdowns": [
|
||||
"### 方法#2",
|
||||
"",
|
||||
"另一种追踪远端分支的方法就是使用选项 : `git branch -u` . ",
|
||||
"",
|
||||
"`git branch -u o/master foo`",
|
||||
"",
|
||||
"这样`foo` 就会跟踪`o/master`了. 如果你处于foo分支, 那么可以省略 foo",
|
||||
"",
|
||||
"`git branch -u o/master`",
|
||||
""
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "GitDemonstrationView",
|
||||
"options": {
|
||||
"beforeMarkdowns": [
|
||||
"看看实际的效果..."
|
||||
],
|
||||
"afterMarkdowns": [
|
||||
"结果跟之前一样, 这个命令的意义更精确!"
|
||||
],
|
||||
"command": "git branch -u o/master foo; git commit; git push",
|
||||
"beforeCommand": "git clone; git checkout -b foo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ModalAlert",
|
||||
"options": {
|
||||
"markdowns": [
|
||||
"好了! 本节我们在不检出`master`的情况下将工作推送到的远端的`master`. 因为这是高级课程, 我会让你自己摸索出技巧! :P"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"de_DE": {
|
||||
"childViews": [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue