I'm trying to undo all changes since my last commit. I tried git reset --hard
and git reset --hard HEAD
after viewing this post. I responds with head is now at 18c3773... but when I look at my local source all the files are still there. What am I missing?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Compile and build with single command line Java (L
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
States transitioning from one commit to new commit
Action for state transitioning
Check diff
Revert to last commit
Equivalent of git clone, without re-downloading anything
there is also
git stash
- which "stashes" your local changes and can be reapplied at a later time or dropped if is no longer requiredmore info on stashing
This will unstage all files you might have staged with
git add
:This will revert all local uncommitted changes (should be executed in repo root):
You can also revert uncommitted changes only to particular file or directory:
Yet another way to revert all uncommitted changes (longer to type, but works from any subdirectory):
This will remove all local untracked files, so only git tracked files remain:
WARNING:
-x
will also remove all ignored files, including ones specified by.gitignore
! You may want to use-n
for preview of files to be deleted.To sum it up: executing commands below is basically equivalent to fresh
git clone
from original source (but it does not re-download anything, so is much faster):Typical usage for this would be in build scripts, when you must make sure that your tree is absolutely clean - does not have any modifications or locally created object files or build artefacts, and you want to make it work very fast and to not re-clone whole repository every single time.
I'm using source tree.... You can do revert all uncommitted changes with 2 easy steps:
1) just need to reset the workspace file status
2) select all unstage files (command +a), right click and select remove
It's that simple :D
If you wish to "undo" all uncommitted changes simply run:
If you have any untracked files (check by running
git status
), these may be removed by running:git stash
creates a new stash which will become stash@{0}. If you wish to check first you can rungit stash list
to see a list of your stashes. It will look something like:Each stash is named after the previous commit messsage.
For those who reached here searching if they could undo
git clean -f -d
, by which a file created in eclipse was deleted,You can do the same from the UI using "restore from local history" for ref:Restore from local history