I am currently running Pygit 0.24.1 (along with libgit 0.24.1), working on a repository where I have two branches (say prodand dev).
Each change is first passed to the branch devand put into the remote repository. For this, I have this piece of code:
repo = Repository('/foo/bar')
repo.checkout('refs/heads/dev')
index = repo.index
index.add('any_file')
index.write()
tree = index.write_tree()
author = Signature('foo', 'foo@bar')
committer = Signature('foo', 'foo@bar')
repo.create_commit('refs/heads/dev', author, committer, 'Just another commit', tree, [repo.head.get_object().hex])
up = UserPass('foo', '***')
rc = RemoteCallbacks(credentials=up)
repo.remotes['origin'].push(['refs/heads/dev'], rc)
This works very well, I see local commit as well as remote commit, and the local repo stays clean:
nothing to commit, working directory inactive
Then I go out into the branch prodand I want to combine the HEAD commit on dev. For this, I use this other piece of code (assuming that I always start checking on a branch dev):
head_commit = repo.head
repo.checkout('refs/heads/prod')
prod_branch_tip = repo.lookup_reference('HEAD').resolve()
prod_branch_tip.set_target(head_commit.target)
rc = RemoteCallbacks(credentials=up)
repo.remotes['origin'].push(['refs/heads/prod'], rc)
repo.checkout('refs/heads/dev')
, , , , . dev.
dev
, : ( "git reset HEAD..." )
: any_file
, . , a git diff . (.. , ). , .
, , , . ?
EDIT. , - FF (Fast-Forward). , FF Pygit2, , .
EDIT 2: @Leon, , git diff , git diff --cached , . , , , , ...
:
- , "12345" + , "54321"
git log , , '54321', git diff --cached :
@@ -1 +1 @@
-54321
+12345