Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / How do you create a remote Git branch?

How do you create a remote Git branch?

August 1, 2021 by James Palmer

First, you create your branch locally:
git checkout -b # Create a new branch and check it out

The remote branch is automatically created when you push it to the remote server. So when you feel ready for it, you can do:
git push

Where is typically origin, the name which git gives to the remote you cloned from. Your colleagues would then just pull that branch, and it’s automatically created locally.
Note however that formally, the format is:
git push :

But when you omit one, it assumes both branch names are the same. Having said this, as a word of caution, do not make the critical mistake of specifying only : (with the colon), or the remote branch will be deleted!
So that a subsequent git pull will know what to do, you might instead want to use:
git push –set-upstream

As described below, the –set-upstream option sets up an upstream branch:

For every branch that is up to date or
successfully pushed, add upstream
(tracking) reference, used by
argument-less git-pull(1) and other
commands.

First, you must create your branch locally
git checkout -b your_branch

After that, you can work locally in your branch, when you are ready to share the branch, push it. The next command push the branch to the remote repository origin and tracks it
git push -u origin your_branch

Teammates can reach your branch, by doing:
git fetch
git checkout origin/your_branch

You can continue working in the branch and pushing whenever you want without passing arguments to git push (argumentless git push will push the master to remote master, your_branch local to remote your_branch, etc…)
git push

Teammates can push to your branch by doing commits and then push explicitly
… work …
git commit
… work …
git commit
git push origin HEAD:refs/heads/your_branch

Or tracking the branch to avoid the arguments to git push
git checkout –track -b your_branch origin/your_branch
… work …
git commit
… work …
git commit
git push

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in