diff options
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r-- | pkg/commands/git.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index e674dc720..dbd9087c2 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -217,11 +217,11 @@ func includesInt(list []int, a int) bool { // ResetAndClean removes all unstaged changes and removes all untracked files func (c *GitCommand) ResetAndClean() error { - if err := c.OSCommand.RunCommand("git reset --hard HEAD"); err != nil { + if err := c.ResetHardHead(); err != nil { return err } - return c.OSCommand.RunCommand("git clean -fd") + return c.RemoveUntrackedFiles() } func (c *GitCommand) GetCurrentBranchUpstreamDifferenceCount() (string, string) { @@ -890,3 +890,18 @@ func (c *GitCommand) DiscardOldFileChanges(commits []*Commit, commitIndex int, f // continue return c.GenericMerge("rebase", "continue") } + +// DiscardAnyUnstagedFileChanges discards any unstages file changes via `git checkout -- .` +func (c *GitCommand) DiscardAnyUnstagedFileChanges() error { + return c.OSCommand.RunCommand("git checkout -- .") +} + +// RemoveUntrackedFiles runs `git clean -fd` +func (c *GitCommand) RemoveUntrackedFiles() error { + return c.OSCommand.RunCommand("git clean -fd") +} + +// ResetHardHead runs `git reset --hard HEAD` +func (c *GitCommand) ResetHardHead() error { + return c.OSCommand.RunCommand("git reset --hard HEAD") +} |