git study notes 5- undo

git revoked four cases, one did not commit, would like to restore all the files; the second is not commit, would like to restore all files; the third is already a commit, want to restore a version; Fourth, the local has submitted, to the remote database restore.

1. not commit, in the workspace, restore all files

If more than one file is modified, not commit, I want to restore. In the inside with svnrevertEnough.
git in the following, can be used

git reset --hard HEAD

All files are restored to the original state.

2. not commit, in the work area, restore a file

If you can just need to pick up a file how to do it? You can use the following command:

git checkout HEAD <file>

3. has been submitted to the Stage, I want to restore a version

git revert <commit>

Look how that one commit it?

git log

4. Local has commit, and would like to recover from a remote library

This situation is completely analogous to svnrevert Command, you can use the following command:

git reset --hard origin/master

The above master can be changed branchxxx

Intelligent Recommendation

Git study notes (5)

Bug branch An interesting little experiment New commands used in this experiment git stash is used to "store" the current work site and continue working after the site is restored in the fut...

GIT study notes(5)

git reset refs/heads/master is a cursor, when a new commit occurs, the master branch will point to the new commit, usegit resetPoint the master (cursor) to any commit id git reset to any commit (1) Pa...

Git study notes 5 - github

GitHub star- A project that focuses on others will appear in your attention sheet fork- Clone someone else's project to a remote repository in your account clone- Method 1: Clone your own remote libra...

Git study notes [5] ---Git Gui

【1】Background In actual development, in order to save time, we do not need to enter instructions 【2】Git Gui (1) Create a version library (2) Add, submit, push Create a file manually Rescan button, you...

Git ignore [study notes] file, view changes, undo changes, view submitted

Ignoring Files Git can be equipped to provide a strong mechanism to allow users to specify files or directories to exclude version control, it checks if there is a file named .gitignore directory code...

More Recommendation

Git study notes: the effect of using reset and checkout to undo changes and the difference between the two

Written in front: This article analyzes in detail the use of reset and checkout in various situations to achieve the effect of undoing the modification. 1. Brief introduction Several simple concepts: ...

Git study notes two (version rollback, work area and temporary storage area, undo modification, delete files)

Git study notes two Version rollback Review the knowledge in Study Note 1 by modifying readme.txt and then adding and submitting it again. As shown: Introduce nowgit logCommand, this is used to view t...

[Study notes] git distributed management (manage modification, undo modification, delete files)

Working directory The workspace is the folder we createdgitTest Repository in the gitTest folder.gitThe folder is the version library, From the screenshot, you can see that there are many things in th...

Liao Xuefeng's Git study notes-2-Undo changes ([add before] git checkout --, [add after] git reset HEAD)-(cancel modification)

Article Directory git status git checkou -- readme.txt `git reset HEAD ` Version rollback section summary natural, You can't make mistakes. But it’s two o’clock in the morning and you&rsqu...

Git study notes (5) - Branch Management

This paper records the principle branch, branch create, delete, merge, and branch usage policies. The role of the branch in practice Suppose you ready to develop a new feature, but two weeks to comple...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top