我有一些关于砂砾/ Git的问题,我希望你能帮助我。这里是我的代码:关于砂砾的几个问题
# create Repo
r = Repo.init_bare 'myrepo.git'
i = r.index
# first commit to master
i.add('myfile.txt', 'my file contents')
i.commit("This is my commit")
# second commit to master
i.read_tree("master")
i.add('myfile2.txt', 'my file 2 contents')
i.commit("This is my second commit", [r.commits.first])
# first commit to newbranch
i.read_tree("master")
i.add('myfile3.txt', 'my file 3 contents')
i.commit("This is my third commit", [r.commits.first], nil, nil, 'newbranch')
# second commit to newbranch
i.read_tree("newbranch")
i.add('myfile4.txt', 'my file 4 contents')
i.commit("This is my fourth commit", [r.commit("newbranch")], nil, nil, 'newbranch')
有了这个代码,我试图创建一个回购协议,提交两次主,创建主一个新的分支,并提交两次该分支。但问题是,当我这样做:
r.commits("newbranch") # => 3
它说,只有3提交“newbranch”。它留下了主人的第二次提交。这是为什么?我的代码有问题吗?
我最混淆是如何指定父提交分支出来的时候,并制作了“newbranch”第二承诺时的事情。
希望你能帮上忙。由于
我在沙砾文档中没有看到这个功能,我的功能也没有?我将如何进行提交?通过索引? – Ronze 2011-04-30 05:49:23
@Ronze https://github.com/mojombo/grit/blob/master/API.txt – manojlds 2011-04-30 05:55:20