git back-off single file

git principle

The Git repository saved a lot of things, most important of which is called the stage (or called index) staging area, and the first branch master Git automatically created for us, and a pointer to the master called HEAD .

git reset command Introduction

git reset for rollback code, with three parameters --hard, - mixed, - soft.

Roll back individual files

  • git log

Acquisition requires a rollback of commit_id.

  • git reset
git reset <commit_id> <file_path>

And then do git status, will find that all changed work area and staging area, suggesting the need for git add and git commit, git reset when the cause is acting on the file, only modifies the staging area. (Repository certainly can not be modified, because only a rollback of the file, the other file is not rolled back, so the entire version can not be rolled back)

  • git checkout
git checkout .

Recover files from the staging area to the work area.

Guess you like

Origin www.cnblogs.com/jmliao/p/11613932.html
Recommended