That will almost work.

When pushing to a non-default branch, you need to specify the source ref and the target ref:

git push origin branch1:branch2

Or

git push <remote> <branch with new changes>:<branch you are pushing to> 
Answer from SLaks on Stack Overflow
Discussions

How to git commit and push to a new remote branch?
I was testing out how git and GitHub works, but now I am lost. So I had three files that I git added, committed, and pushed to the master branch onโ€ฆ More on reddit.com
๐ŸŒ r/git
4
1
October 27, 2020
git - How can I push a specific commit to a remote, and not previous commits? - Stack Overflow
For example, to push everything but the last commit with some standard names git push origin HEAD~1:master. 2013-05-01T20:58:56.367Z+00:00 ... Also note, that if you have already pushed a later SHA to that remote branch, then you will need to force push this one. More on stackoverflow.com
๐ŸŒ stackoverflow.com
a question about pushing changes to a branch in a repo (not the master branch)
You'd push the new branch to the remote. Simply do git push and git will tell you how to set the remote tracking branch initially. Your previous branches will still be around. You won't lose any data when pushing unless you use the -f or --force option. More on reddit.com
๐ŸŒ r/git
7
6
April 27, 2021
How do I push a new local branch to a remote Git repository and track it too? - Stack Overflow
Edit files, add and commit. Then push with the -u (short for --set-upstream) option: ... Git will set up the tracking information during the push. ... Sign up to request clarification or add additional context in comments. ... It's also worth noting that if you have an existing tracking branch ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Atlassian
atlassian.com โ€บ git โ€บ tutorials โ€บ syncing โ€บ git-push
Git Push | Atlassian Git Tutorial
1# make changes to a repo and git add 2git commit --amend 3# update the existing commit message 4git push --force origin main ยท The above example assumes it is being executed on an existing repository with a commit history. git commit --amend is used to update the previous commit.
๐ŸŒ
GitHub
github.com โ€บ git-guides โ€บ git-push
Git Guides - git push ยท GitHub
Then, push the new branch up to the remote: git push -u origin [branchname] Checkout to the branch that you intended to commit to: git checkout [branchname] Merge the commits from the branch that you did accidentally commit to: git merge [main] ...
๐ŸŒ
Git
git-scm.com โ€บ docs โ€บ git-push
Git - git-push Documentation
In the following rules "update" ... forbidden by configuration or hooks. If the push destination is a branch (refs/heads/*): only fast-forward updates are allowed, which means the destination must be an ancestor of the source commit....
๐ŸŒ
GitLab
docs.gitlab.com โ€บ topics โ€บ git โ€บ commit
Stage, commit, and push changes | GitLab Docs
As a rule, always check the status ... to a repository. Instead, you must force an update. ... When you push changes to a branch, you can use client-side Git push options....
๐ŸŒ
Reddit
reddit.com โ€บ r/git โ€บ how to git commit and push to a new remote branch?
r/git on Reddit: How to git commit and push to a new remote branch?
October 27, 2020 - Then I made a new local branch (from the local master branch), but could not find files to add (working tree clean). ... That makes sense, because you've already added and committed them. git show should show you this. ... GIT PUSH Question how to use correctly?
Find elsewhere
๐ŸŒ
Medium
frankgwarman.medium.com โ€บ the-first-pull-commit-and-push-with-git-fb620b0e630b
The first Pull, Commit, and Push with Git! | by Frank Warman | Medium
June 20, 2023 - The git commit command only commits to your local branches. You will not be able to interact with these online, yet. Pushing your local commit to the remote server will complete the process!
Top answer
1 of 7
1535

To push up through a given commit, you can write:

git push <remotename> <commit SHA>:<remotebranchname>

provided <remotebranchname> already exists on the remote. (If it doesn't, you can use git push <remotename> <commit SHA>:refs/heads/<remotebranchname> to autocreate it.)

If you want to push a commit without pushing previous commits, you should first use git rebase -i to re-order the commits.

2 of 7
166

The other answers are lacking on the reordering descriptions.

git push <remotename> <commit SHA>:<remotebranchname>

will push a single commit, but that commit has to be the OLDEST of your local, non-pushed, commits, not to be confused with the top, first, or tip commit, which are all ambiguous descriptions in my opinion. The commit needs to be the oldest of your commits, i.e. the furthest from your most recent commit. If it's not the oldest commit then all commits from your oldest, local, non-pushed SHA to the SHA specified will be pushed. To reorder the commits use:

git rebase -i HEAD~xxx

After reordering the commit you can safely push it to the remote repository.

To summarize, I used

git rebase -i HEAD~<number of commits to SHA>
git push origin <post-rebase SHA>:master

to push a single commit to my remote master branch.

References:

  1. http://blog.dennisrobinson.name/push-only-one-commit-with-git/
  2. http://blog.dennisrobinson.name/reorder-commits-with-git/

See also:

  1. git: Duplicate Commits After Local Rebase Followed by Pull
  2. git: Pushing Single Commits, Reordering with rebase, Duplicate Commits
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ dataspell โ€บ commit-and-push-changes.html
Commit and push changes to Git repository | DataSpell Documentation
November 6, 2025 - DataSpell allows you to upload changes from any branch to its tracked branch or to any other remote branch. ... To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ git-push-pull
Git Push and Pull Tutorial | DataCamp
July 23, 2019 - You can change the word "containnns" to "contains" in the README file, and the changes with the current status can be viewed by using the following command. You need to add and commit by using the following commands. You need to push the content by git push origin 'branch_name'.
๐ŸŒ
DEV Community
dev.to โ€บ projectpage โ€บ how-to-move-a-commit-to-another-branch-in-git-4lj4
How to move a commit to another branch in git - DEV Community
September 21, 2019 - Using git reset --hard will remove all the commit referencing the changes, and all the changes themselves, from feature-a branch, while leaving that commit on feature-b: ... You can do this with multiple commits too, just cherry pick several, then reset back to the last commit you want to keep. The process is the same if you have committed to local master by mistake - just cherry-pick to a branch, then reset master. Only ever do this if you haven't pushed the commits to origin.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-commit-and-push-at-same-time-in-Git
How to commit and push at same time in Git - Quora
To commit and push in one step in Git, use a single command that creates a commit and then pushes it to a remote. There are several simple options depending on your workflow and shell.
๐ŸŒ
TheServerSide
theserverside.com โ€บ blog โ€บ Coffee-Talk-Java-News-Stories-and-Opinions โ€บ git-push-new-branch-remote-github-gitlab-upstream-example
Git push new local branch to remote
Continue to perform Git commits locally on the new branch. Simply use the git push origin command on subsequent pushes of the new branch to the remote repo. These steps assume you have already established connectivity to the remote Git repository.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ pushing-changes-to-a-git-repository
Pushing Changes to a Git Repository - GeeksforGeeks
July 12, 2025 - ... After the user is done with the modifications in the Local repository, there is a need to push these changes to the remote repository. This can be done with the git push command. Users can define which branch is to be pushed into the repository ...
๐ŸŒ
Graphite
graphite.com โ€บ guides โ€บ git-commit-to-new-branch
How to commit to a new branch in Git - Graphite
... The -m flag allows you to add a commit message directly in the command line. Using the Graphite CLI: If you need to make additional changes and commit them: ... The gt modify --all command will stage and commit all modifications.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ git โ€บ how-to-push-a-specific-commit-to-remote-in-git
How To Push a Specific Commit to Remote in Git? - GeeksforGeeks
July 23, 2025 - If you need to apply a specific commit to another branch without creating a new branch, you can use cherry-pick: ... Follow the instructions in the editor to pick, reword, or squash commits. ... Pushing a specific commit to a remote repository can be essential for maintaining a clean and organized codebase.
๐ŸŒ
GitHub
github.com โ€บ marketplace โ€บ actions โ€บ commit-and-push-branch
Marketplace - Actions - Commit and Push Branch
This action is useful if you want to push and test an additional commit based on changes from previous steps or actions to some branch. Please note, you could easily end up in a neverending recursion loop, where you modify the repository, push the change to a branch (whether the src or the destination), and the workflow runs again. It's recommended that you setup the workflow using this action to trigger on: [pull_request], and the dest-branch to be different than the src branch. Verifying the github checks is optional, as well as the ability to delete the newly created branch.