I am using pygit2 to merge some branches of a project, however whenever I merge them I end up with:
def avoid_walls(directions, board, snake):
<<<<<<< HEAD
return directions
=======
z = 1
moves = []
for direction in directions:
new_x = snake[0][0] + dirs[direction][0]
new_y = snake[0][1] + dirs[direction][1]
if new_x >= 0 and new_x < len(board[0]) and new_y >= 0 and new_y < len(board):
moves.append(direction)
return moves
>>>>>>> 357f58b6d1682760b2fa9bf7b2418da347ca353c
in my code. When I check the repo with 'git status' I find this:
HEAD detached from origin/master
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
As far as I can tell I am doing everything properly, so I cant figure out why the HEAD is detached. From my understanding, the HEAD is detached when you check out a specific commit, rather than a branch, which I am not doing:
# clone repo to local directory
repo = pygit2.clone_repository(my_repo, my_dir)
# checkout master branch (checked out by default, but just to be safe)
repo.checkout('refs/remotes/origin/master')
# merge with other branches
repo.merge(repo.branches['origin/branch1'].target)
# commit changes
index = repo.index
index.add_all()
index.write()
author = pygit2.Signature("ME", "me@domain.com")
commiter = pygit2.Signature("ME", "me@domain.com")
tree = index.write_tree()
oid = repo.create_commit('refs/heads/master', author, commiter, "init commit", tree, [repo.head.target, repo.branches['origin/branch1'].target])
#some tests i tried to fix the issue
repo.head.set_target(oid)
repo.apply(oid)
Am I missing something after the merge that will complete the commit and resolve this issue?