Method: Rugged::Repository#reset

Defined in:
ext/rugged/rugged_repo.c

#reset(target, reset_type) ⇒ nil

Sets the current head to the specified commit oid and optionally resets the index and working tree to match.

  • target: Rugged::Commit, Rugged::Tag or rev that resolves to a commit or tag object

  • reset_type: :soft, :mixed or :hard

:soft

the head will be moved to the commit.

:mixed

will trigger a :soft reset, plus the index will be replaced with the content of the commit tree.

:hard

will trigger a :mixed reset and the working directory will be replaced with the content of the index. (Untracked and ignored files will be left alone)

Examples:

repo.reset('origin/master', :hard) #=> nil

Returns:

  • (nil)
[View source]

1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
# File 'ext/rugged/rugged_repo.c', line 1824

static VALUE rb_git_repo_reset(VALUE self, VALUE rb_target, VALUE rb_reset_type)
{
	git_repository *repo;
	int reset_type;
	git_object *target = NULL;
	int error;

	Data_Get_Struct(self, git_repository, repo);

	reset_type = parse_reset_type(rb_reset_type);
	target = rugged_object_get(repo, rb_target, GIT_OBJ_ANY);

	error = git_reset(repo, target, reset_type, NULL);

	git_object_free(target);

	rugged_exception_check(error);

	return Qnil;
}