2012-08-08 13 views

答えて

6

class git.refs.head.HEAD(repo, path='HEAD')

reset(commit='HEAD', index=True, working_tree=False, paths=None, **kwargs)

は、与えられたに私たちの頭をリセットは、必要に応じてインデックスを同期して、ツリーを作業犯します。参照する参照はコミットにも設定されます。

を使用でき
10

repo = git.Repo('c:/SomeRepo') 
repo.git.reset('--hard') 

それとも、特定のブランチにリセットする必要がある場合:あなただけハードにレポを更新したい場合は、

repo.git.reset('--hard','origin/master') 

それとも私の場合origin/master(警告、現在の変更はありません):

# blast any current changes 
repo.git.reset('--hard') 
# ensure master is checked out 
repo.heads.master.checkout() 
# blast any changes there (only if it wasn't checked out) 
repo.git.reset('--hard') 
# remove any extra non-tracked files (.pyc, etc) 
repo.git.clean('-xdf') 
# pull in the changes from from the remote 
repo.remotes.origin.pull() 
1

Y使用できる:

repo = git.Repo('repo') 
# ... 
# Remove last commit 
repo.head.reset('HEAD~1', index=True, working_tree=True) 
関連する問題