Just do:
git push origin <your_branch_name> --force
or if you have a specific repo:
git push https://git.... --force
This will delete your previous commit(s) and push your current one.
It may not be proper, but if anyone stumbles upon this page, thought they might want a simple solution…
Short flag
Also note that -f
is short for --force
, so
git push origin <your_branch_name> -f
will also work.
Related Posts:
- What does ‘–set-upstream’ do?
- What does ‘–set-upstream’ do?
- What are the differences between “git commit” and “git push”?
- How do I delete a Git branch locally and remotely?
- How do I delete a Git branch locally and remotely?
- error: src refspec master does not match any
- What is the difference between git push origin and git push origin master
- How do I push a new local branch to a remote Git repository and track it too?
- How do I push a new local branch to a remote Git repository and track it too?
- How do I push a new local branch to a remote Git repository and track it too?
- How do you push a tag to a remote repository using Git?
- rejected master -> master (non-fast-forward)
- rejected master -> master (non-fast-forward)
- Meaning of the GitHub message: push declined due to email privacy restrictions
- Git Giving “fetch first” error when trying to push
- git – Your branch is ahead of ‘origin/master’ by 1 commit
- ! [rejected] master -> master (fetch first)
- Set up git to pull and push all branches
- Undoing a ‘git push’
- What does git push origin HEAD mean?
- What does git push origin HEAD mean?
- How do I push a local Git branch to master branch in the remote?
- git push not send changes to remote git repository
- Git push hangs when pushing to Github?
- How can I push a specific commit to a remote, and not previous commits?
- Git Push Error: insufficient permission for adding an object to repository database
- Git push requires username and password
- How do I check out a remote Git branch?
- How to use Git Revert
- Git merge hotfix branch into feature branch
- Git submodule update
- What does ‘git merge –abort is equivalent to git reset –merge when MERGE_HEAD is present.’ of Git merge man page mean?
- How do I clone a specific Git branch? [duplicate]
- What does “Changes not staged for commit” mean
- Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
- git: fatal: Could not read from remote repository
- How do I update Homebrew?
- Git error when trying to push — pre-receive hook declined
- Remove files from Git commit
- How to solve SSL certificate: self signed certificate when cloning repo from github?
- Gitignore not working
- How do I revert a Git repository to a previous commit?
- How to revert multiple git commits?
- How do I fix a Git detached head?
- Why does git say “Pull is not possible because you have unmerged files”?
- How can I git stash a specific file?
- Move the most recent commit(s) to a new branch with Git
- What does “Git push non-fast-forward updates were rejected” mean?
- How do I diff the same file between two different commits on the same branch?
- How to name and retrieve a stash by name in git?
- You have not concluded your merge (MERGE_HEAD exists)
- How to get the current branch name in Git?
- Stash just a single file
- Git error on commit after merge – fatal: cannot do a partial commit during a merge
- Is there a “theirs” version of “git merge -s ours”?
- Is there a command to undo git init?
- Download a single folder or directory from a GitHub repo
- fatal: Not a valid object name: ‘master’
- Git and nasty “error: cannot lock existing info/refs fatal”
- Is there a “git touch” so I can push the same file with a new timestamp?
- Branch from a previous commit using Git
- How do I delete a local repository in git?
- Throw away local commits in Git
- Hard reset of a single file
- Not a valid object name: ‘master’
- git add remote branch
- How do I copy a version of a single file from one Git branch to another?
- Undo a git stash
- Undo git stash pop that results in merge conflict
- Git: cannot checkout branch – error: pathspec ‘…’ did not match any file(s) known to git
- Git Push ERROR: Repository not found
- Why does Git tell me “No such remote ‘origin'” when I try to push to origin?
- Unity Collaborate vs GitHub
- How do I clone a single branch in Git?
- how to reset develop branch to master
- “fatal: HttpRequestException encountered.” Error with GitHub/Bitbucket Repositories due to dropping TLS-1.0 support
- SourceTree keeps asking for Github password
- How to change the license for a project at Github?
- Git add all files modified, deleted, and untracked?
- How to switch back to ‘master’ with git?
- fatal: could not read Username for ‘https://github.com’: No such file or directory
- Github Authentication Failed – … GitHub does not provide shell access
- How do I pull files from remote without overwriting local files?
- How to keep a branch synchronized/updated with master?
- TortoiseGit-git did not exit cleanly (exit code 1)
- How to `git pull` while ignoring local changes?
- Your repository has no remotes configured to push to
- Uninitialize git repository
- Specify an SSH key for git push for a given domain
- How do I “un-revert” a reverted Git commit?
- How to merge a specific commit in Git
- What is the .git folder?
- How to use Git and Dropbox together?
- Git: Where exactly is the “working directory”?
- What exactly does the “u” do? “git push -u origin master” vs “git push origin master”
- Collaboratively develop a WordPress site
- Add latest commit info on login footer using login_footer hook
- WordPress Core files not being ignored by Git
- Display GitLab repositories of the logged in user on a page
- Full site editor, hard-coded IDs in query blocks, and staging/dev servers