In Git 1.7.0 and later, you can checkout a new branch:

git checkout -b <branch>

Edit files, add and commit. Then push with the -u (short for --set-upstream) option:

git push -u origin <branch>

Git will set up the tracking information during the push.

Answer from Daniel Ruoso on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › git-push-local-branch-to-remote-how-to-publish-a-new-branch-in-git
Git Push Local Branch to Remote – How to Publish a New Branch in Git
September 9, 2022 - To confirm the remote has been added, run git remote -v: To finally push the repo, run git push -u origin <branch-name> (“main” is the name of that branch for me). It could be master or Main for you.
Discussions

Push to remote repository
I want to push my files into a remote repository. Below are the steps that i have followed. I created an empty private repository on Gitlab. 1)I cloned the repository to a local folder on my lsf using git clone. 2)I created a new branch → test1 3)created a new file → Jenkinsfile.txt and ... More on forum.gitlab.com
🌐 forum.gitlab.com
1
0
November 25, 2020
How to properly push local branch to remote branch?
git push origin branch_a More on reddit.com
🌐 r/git
6
1
March 12, 2018
How to create a branch on remote and push to it?
Say I'm on main and want to create a new branch to be tracked on remote, we'll call it branch for brevity. In the CLI, I would git checkout -b branch, edit, add, and commit, until finally doing a git push -u origin branch. That makes a new branch on remote, and then my local branch branch will ... More on github.com
🌐 github.com
2
2
Pushing a local merged branch to the remote main branch
Just git push [origin [main]] like usual. If that fails, post the error message. But if the remote and local main branch were identical before the merge, there should be no problem. (If the remote branch's commit is a direct ancestor of the local one's, Git just takes all those commits inbetween and pushes them to the remote) More on reddit.com
🌐 r/git
3
0
November 4, 2023
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-push-a-local-branch-to-a-remote-repository-in-git
How to Push a Local Branch to a Remote Repository in Git? - GeeksforGeeks
July 23, 2025 - ... Pushing a local branch to a remote repository involves creating a branch locally, making some changes, committing those changes, and then pushing the branch to the remote repository so that others can access it.
🌐
GitHub
docs.github.com › en › get-started › using-git › pushing-commits-to-a-remote-repository
Pushing commits to a remote repository - GitHub Docs
As an example, you usually run git push origin main to push your local changes to your online repository. To rename a branch, you'd use the same git push command, but you would add one more argument: the name of the new branch.
🌐
freeCodeCamp
freecodecamp.org › news › git-push-to-remote-branch-how-to-push-a-local-branch-to-origin
Git Push to Remote Branch – How to Push a Local Branch to Origin
April 26, 2021 - Total 1 (delta 0), reused 0 (delta 0) To github.com:johnmosesman/burner-repo.git + edb64e2...52f54da my-feature -> my-feature (forced update) (Note: you can use -f as a shorthand instead of --force.) A force push is a destructive action—only use it when you're certain it's what you want to do. Sometimes you may want to force push—but only if no one else has contributed to the branch. If someone else contributes to your branch and pushes up their changes to the remote—and you force push over it—you will overwrite their changes.
🌐
GitHub
gist.github.com › 8521884
Push a new local branch to remote · GitHub
Save willmcneilly/8521884 to your computer and use it in GitHub Desktop. Download ZIP · Push a new local branch to remote · Raw · push_new_branch_to_remote.sh · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
Find elsewhere
🌐
Better Stack
betterstack.com › community › questions › how-to-create-remote-branch
How Do I Create a Remote Git Branch? | Better Stack Community
June 24, 2024 - To make an existing Git branch track a remote branch, you can use the -u or --set-upstream-to option with the git branch command or the -u or --set-upstream option with the git push command.
🌐
Javaiq
javaiq.in › 2020 › 04 › push-new-local-branch-to-remote-git.html
Java Study Point (Java iQ): Push a new local branch to a remote Git repository
April 1, 2020 - Push a new local branch to a remote Git repository,How to Push a new local branch to a remote Git repository
🌐
GitLab
forum.gitlab.com › how to use gitlab
Push to remote repository - How to Use GitLab - GitLab Forum
November 25, 2020 - I want to push my files into a remote repository. Below are the steps that i have followed. I created an empty private repository on Gitlab. 1)I cloned the repository to a local folder on my lsf using git clone. 2)I created a new branch → test1 3)created a new file → Jenkinsfile.txt and ...
🌐
devconnected
devconnected.com › home › software engineering › how to push git branch to remote
How To Push Git Branch To Remote – devconnected
February 15, 2020 - As an example, let’s say that ... your branch to the “feature” branch, you would execute the following command · $ git push origin my-feature:feature Enumerating objects: 6, done....
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-push-git-branch-to-remote
Push Git Branch to Remote - GeeksforGeeks
March 17, 2026 - Note: If no remote is configured, running git push will result in an error. ... This command pushes the local main branch to the remote repository.
🌐
GitHub
gist.github.com › aemkei › 102432 › 490ee89d234c77d241b85b03626126940eddbe19
push existing local branch to remote · GitHub
Save aemkei/102432 to your computer and use it in GitHub Desktop. Download ZIP · push existing local branch to remote · Raw · 0. create local branch · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Squash
squash.io › how-to-push-and-track-a-local-branch-in-git
How To Push And Track A Local Branch In Git
September 18, 2023 - The -u option sets the upstream branch for the local branch, allowing you to track changes and easily push future updates. The origin parameter specifies the remote repository where you want to push the branch. Related Article: How to Perform a Hard Reset of a Single File in Git
🌐
Techulator
techulator.com › resources › 21047-how-to-push-git-branch-to-remote
How To Push Git Branch To Remote
July 2, 2022 - Push Branch to Another Branch You ... repository. Use the "git push" command and supply the remote name, your local branch's name, as the remote branch's name, to push your branch to another remote branch....
🌐
Graphite
staging-graphite-splash.vercel.app › guides › change-branch-remote
How to change a branch's remote
... Replace origin/another-branch with the new remote branch you want to track. Creating and pushing a branch in one command: You can use git push -u origin new-feature to both create the remote branch and set your local branch to track it in ...
🌐
Namehero
namehero.com › blog › how-to-use-git-to-push-to-a-different-remote-branch
How to Use Git to Push to a Different Remote Branch
October 24, 2024 - The first step is to ensure that you’ve added and committed the changes you’ve made to your local branch. You can start by checking the status of your git project: ... Now let’s say that instead of choosing to push our changes to the “main” branch on the remote repo, we want to push to a new branch called “alternate-feature”. This branch may or may not exist on the remote repo.
🌐
Reddit
reddit.com › r/git › how to properly push local branch to remote branch?
r/git on Reddit: How to properly push local branch to remote branch?
March 12, 2018 -

TL;DR How to push changes in branch_a from local repo to contents of branch_a on remote repo?


Hi all. In my local repo, I have a branch ("branch_a") and have made commits to a file inside that branch. How do I push these changes to my remote repository? My remote repository already contains this branch (as well as all files inside). Will git push be smart enough to push these changes to "branch_a" in my remote repo? Or will it push the changes into my remote repo master branch instead?

Here is the output of cat .git/config:

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = git@gitlab.example.net:username/redirects-horizon-homes.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "branch_a"]
        remote = origin
        merge = refs/heads/branch_a

Thanks in advance.

🌐
freeCodeCamp
freecodecamp.org › news › git-pull-remote-branch-how-to-fetch-remote-branches-in-git
Git Pull Remote Branch – How To Fetch Remote Branches in Git
November 7, 2024 - This ensures that fetching is a safe way to review commits before integrating them into your local repository. If you want to fetch remote branches and merge them with your work or modify your current work, you can use the git pull command.
🌐
GeeksforGeeks
geeksforgeeks.org › git › git-pull-remote-branch
Git Pull Remote Branch - GeeksforGeeks
February 26, 2026 - Common commands to sync local branches with remote changes and manage remote branches. git pull <remote> <branch>: Fetches changes from the specified remote branch and merges them into your current branch.