If you want to revert changes made to your working copy, do this:
git checkout .
If you want to revert changes made to the index (i.e., that you have added), do this. Warning this will reset all of your unpushed commits to master!:
git reset
If you want to revert a change that you have committed, do this:
git revert <commit 1> <commit 2>
If you want to remove untracked files (e.g., new files, generated files):
git clean -f
Or untracked directories (e.g., new or automatically generated directories):
git clean -fd
Related Posts:
- How do I revert all local changes in Git managed project to previous state?
- How do I check out a remote Git branch?
- What is git tag, How to create tags & How to checkout git remote tag(s)
- How do I revert a Git repository to a previous commit?
- How can I switch to another branch in git?
- How to get just one file from another branch?
- How do I revert a Git repository to a previous commit?
- How can I reset or revert a file to a specific revision?
- What’s the difference between git switch and git checkout
- git checkout tag, git pull fails in branch
- Git: How to update/checkout a single file from remote origin master?
- git checkout master error: the following untracked working tree files would be overwritten by checkout
- How do I “un-revert” a reverted Git commit?
- Git checkout – switching back to HEAD
- git checkout all the files
- How do I delete a Git branch locally and remotely?
- Difference between “git add -A” and “git add .”
- Git: Message ‘src refspec master does not match any’ when pushing commits in Git
- error: src refspec master does not match any
- How to cherry pick from 1 branch to another
- How to Git stash pop specific stash in 1.8.3?
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- Updates were rejected because the tip of your current branch is behind its remote counterpart
- git stash apply version
- Git fetch remote branch
- Updating a local repository with changes from a GitHub repository
- How do I remove a submodule?
- Git push results in “Authentication Failed”
- Git push results in “Authentication Failed”
- Download single files from GitHub
- Undoing a git rebase
- How to resolve merge conflicts in a Git repository
- Ignoring directories in Git repositories on Windows
- How can I merge multiple commits onto another branch as a single squashed commit?
- How do I resolve git saying “Commit your changes or stash them before you can merge”?
- How to find my GitHub username so that I can be found via the URL?
- Create Git branch with current changes
- github website publish cannot publish unborn HEAD
- The following untracked working tree files would be overwritten by merge, but I don’t care
- Why do I have to “git push –set-upstream origin
“? - How do you create a remote Git branch?
- Move the most recent commit(s) to a new branch with Git
- rejected master -> master (non-fast-forward)
- How to name and retrieve a stash by name in git?
- Create a tag in a GitHub repository
- How can I delete a file from a Git repository?
- Git: Could not resolve host github.com error while cloning remote repository in git
- How to pull a specific branch from Github
- Make an existing Git branch track a remote branch?
- How to fully delete a git repository created with init?
- How do you create a remote Git branch?
- How do I update or sync a forked repository on GitHub?
- Files not updating using ‘git pull’
- Pull request vs Merge request
- What is the difference between `git merge` and `git merge –no-ff`?
- The following untracked working tree files would be overwritten by merge, but I don’t care
- error: cannot lock ref.. ‘refs/tags’ exists; cannot create ‘refs/tags/
- Your configuration specifies to merge with the
from the remote, but no such ref was fetched.? - ! [rejected] master -> master (fetch first)
- How to git add a whole folder
- How to change folder with git bash?
- Git:nothing added to commit but untracked files present
- Git how to clone with SSH key, username
- fatal: This operation must be run in a work tree
- How to replace local branch with remote branch entirely in Git?
- Git diff against a stash
- How to revert a “git rm -r .”?
- “git checkout
” is changing branch to “no branch” - How do I push a local Git branch to master branch in the remote?
- How to clone git repository with specific revision/changeset?
- How to compare a local Git branch with its remote branch
- How do I list all of the files in a commit?
- Git keeps prompting me for a password
- How to permanently remove few commits from remote branch
- Resolve Git merge conflicts in favor of their changes during a pull
- Git stash pop- needs merge, unable to refresh index
- Found a swap file by the name
- Is there a git-merge –dry-run option?
- Add all files to a commit except a single file?
- How do I run git log to see changes only for a specific branch?
- failed to push some refs to [email protected]
- How to update Git clone
- Sourcetree adding files in global .gitignore, not in repository .gitignore
- Difference between git stash pop and git stash apply
- git pull remote branch cannot find remote ref
- How do I show the changes which have been staged?
- How do I change the default location for Git Bash on Windows?
- Git push hangs when pushing to Github?
- Does running git init twice initialize a repository or reinitialize an existing repo?
- Eclipse EGit Checkout conflict with files: – EGit doesn’t want to continue
- Git Push Error: insufficient permission for adding an object to repository database
- Git push requires username and password
- WordPress with Git
- WordPress Git Workflow Help
- Multiple copies of the same website: how to organize code/architecture?
- Version control with a team of non-developers
- Questions about Git and WordPress [duplicate]
- What’s is the best stack for cPanel continuous deployment?
- How to tell which local branch is tracking which remote branch in Git?
- How do I edit git’s history to correct an incorrect email address/name [closed]