If your excess commits are only visible to you, you can just do
git reset --hard origin/<branch_name>
to move back to where the origin is. This will reset the state of the repository to the previous commit, and it will discard all local changes.
Doing a git revert
makes new commits to remove old commits in a way that keeps everyone’s history sane.
Related Contents:
- Removing multiple files from a Git repo that have already been deleted from disk
- .gitignore and “The following untracked working tree files would be overwritten by checkout”
- Change first commit of project with Git? [duplicate]
- GitHub “fatal: remote origin already exists”
- What’s the difference between ‘git merge’ and ‘git rebase’?
- How can I view prior commits with git blame?
- Why did my Git repo enter a detached HEAD state?
- Add only non-whitespace changes
- Update a submodule to the latest commit
- List files in local git repo?
- How can I archive git branches?
- What is the difference between git pull and git fetch + git rebase?
- Git: Merge a Remote branch locally
- Can I make fast forwarding be off by default in git?
- Install specific git commit with pip
- What are some good ways to manage a changelog using Git? [closed]
- Git merge error “commit is not possible because you have unmerged files”
- Git: copy all files in a directory from another branch
- How do you push a Git tag to a branch using a refspec?
- In a git merge conflict, what are the BACKUP, BASE, LOCAL, and REMOTE files that are generated?
- How to git ignore ipython notebook checkpoints anywhere in repository
- Why am I merging “remote-tracking branch ‘origin/develop’ into develop”?
- GitHub authentication failing over https, returning wrong email address
- Redo merge of just a single file
- github/git Checkout Returns ‘error: invalid path’ on Windows
- Remove old git commits
- How to use git commands after enable gitlab’s second-factor authentication
- Git Pull is Not Possible, Unmerged Files
- Git for Windows: SSL certificate problem: certificate has expired
- Move tag one commit ahead
- How to see all local commits which are not pushed to the remote branch?
- GIT repository over LAN
- Git pull into wrong branch
- Line history viewer – Git
- How to update Git clone
- Git how to checkout a commit of a branch
- Unable to determine upstream SVN information from HEAD history
- git export from github remote repository
- What does “~ (END)” mean when displayed in a terminal?
- git pull and resolve conflicts
- Can I view the reflog of a remote (not remote ref)?
- git pull –rebase vs git rebase : what’s the danger?
- What is github ‘compare & pull request’
- Proper way to use Gitflow with pull requests
- “git checkout ” is changing branch to “no branch”
- Change connected commit on release github
- Git says a file is unmerged and I can’t commit, but the file seems to be merged
- Check if specific file in git repository has changed
- TortoiseGit-git did not exit cleanly (exit code 1)
- Git merge flattening