提交一些文件后,本地文件会被更改。现在我想将本地目录恢复到与上次提交完全相同的状态。在下图中,本地未提交的更改已损坏,因此我想取出主基本操作符....我已经尝试git reset [the first commit hash code from git log]
,但没有任何更改。
答案 0 :(得分:1)
git reset <commit>
会更改您的HEAD所指向的位置,但不会将您的文件恢复到该提交的状态。如果要将文件还原到提交的查看方式,则需要git reset --hard <commit>
关于三种重置模式:
--soft
Does not touch the index file or the working tree at all (but
resets the head to <commit>, just like all modes do). This
leaves all your changed files "Changes to be committed", as git
status would put it.
--mixed
Resets the index but not the working tree (i.e., the changed
files are preserved but not marked for commit) and reports what
has not been updated. This is the default action.
If -N is specified, removed paths are marked as intent-to-add
(see git-add(1)).
--hard
Resets the index and working tree. Any changes to tracked files
in the working tree since <commit> are discarded.
答案 1 :(得分:0)
我想将本地目录恢复到与上次提交完全相同的状态。在下图中,本地未提交的更改已损坏
如果要放弃本地未提交的更改,请执行try
{
SQL = "INSERT INTO payment_history_tbl (id, payment_type, date, time, amount, student_no) VALUES (NULL, '" + cmbbxPaymentType.Text + "', CURRENT_DATE(), CURRENT_TIME(), '" + txtbxPaymentAmt.Text + "', '" + msktxbxStudNo.Text + "'";
// INSERT INTO `studentpaymentqueuing`.`payment_history_tbl` (`id`, `payment_type`, `date`, `time`, `amount`, `student_no`) VALUES (NULL, 'Certificate of Enrollment', '2017-02-24', '10:19:28', '60.00', '13-0695');
cmd = new MySqlCommand(SQL, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
(返回上次提交)
reset HEAD