How to push a local branch to a remote repository?

git push -u origin branch_name

To push a local branch to a remote repository and track it use git push -u origin branch_name.

In case there are new remote changes in your branch, you can pull them with git pull.

After tracking is set up, you can push your changes to the remote repository with git push.

Layer 1
Terminal Example
git status
On branch new-branch
nothing to commit, working tree clean

git push -u origin new-branch
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'new-branch' on GitHub by visiting:
remote:      https://github.com/githint/playground-remote/pull/new/new-branch
remote:
To github.com:githint/playground-remote.git
 * [new branch]      new-branch -> new-branch
Branch 'new-branch' set up to track remote branch 'new-branch' from 'origin'.

git status
On branch new-branch
Your branch is up to date with 'origin/new-branch'.

nothing to commit, working tree clean

See git push to learn more about it.

Last modified on November 30, 2021.

You might also like