zoukankan      html  css  js  c++  java
  • Create a commit using pygit2

    Create a commit using pygit2

    Create a commit using pygit2

    I would like to make a commit on a branch (master for example).

    I am making a repository clone using pygit2 (pygit2.clone_repository)

    Then I change an existing file in the repository.

    Afterwards I run this to make a commit:

    index = repository.index
    index.add_all()
    index.write()
    author = pygit2.Signature(user_name, user_mail)
    commiter = pygit2.Signature(user_name, user_mail)
    tree = repository.TreeBuilder().write()
    oid = repository.create_commit(reference, author, commiter, message,tree,[repository.head.get_object().hex])
    

    But when i go to the repository and run git status:

    On branch master
    Changes to be committed:
    (use "git reset HEAD <file>..." to unstage)
    new file:   test.txt
    

    The modified file seems to be added for commit but the commit did not succeed. Using the returned Oid i can find the commit attribute in the pygit2 repository.

    Did I miss something ?

  • 相关阅读:
    柱状图最大的矩形
    单词搜索
    最小覆盖子串
    颜色分类
    编辑距离
    X的平方根
    二进制求和
    最大子序和
    N皇后
    java8-14-时间API
  • 原文地址:https://www.cnblogs.com/lexus/p/5286267.html
Copyright © 2011-2022 走看看