Creating A Branch In Remote Git Repository - TecAdmin

Close Menu Facebook X (Twitter) Instagram Tuesday, December 9 TecAdmin TecAdmin Git Tips: How to Create a Remote BranchBy RahulApril 26, 20252 Mins Read

Branching makes efficient ways to manage versioning of your application code. The popular version management tools supported branches like Git, SVN etc. Development in branching make process easier by splitting code in branches per modules.

Most of the Git providers (like: github.com, gitlab.com etc) provides option to create branch directly with web interface. But, in case you don’t have web interface access, You can also do the same by creating a branch in local repository and push changes to remote.

This article will help you to create a branch on local repository and then push branch to the remote Git repository.

1. Local Branch You Want to Publish

Switch to the local repository branch you want to publish to remote. To do this, use the following command:

git checkout feature-branch

Replace feature-login with a descriptive name for your new branch. This command creates a new branch and switches to it immediately.

In case, the local branch doesn’t yet exist, you can easily create it:

git checkout -b feature-login

2. Push the Local Branch to the Remote Repository

In order to share your local branch with others or to work on it from another computer, you need to push it to a remote repository. To do this, first, make sure you have a remote repository set up. If you’re using GitHub, GitLab, or Bitbucket, create a new repository on their platform.

Now, you’re ready to push your local branch to the remote repository. Use the following command:

git push -u origin feature-branch

This command pushes your local branch (“feature-login”) to the remote repository and sets up a tracking relationship between the local and remote branches.

You can also push the branch with another name to remote.

git push -u origin feature-branch:new-branch-name

Conclusion

Creating local and remote Git branches is an essential skill for developers working with version control. It allows you to work on multiple features or fixes simultaneously, without affecting the main branch. By following the steps outlined in this article, you’ll be well-equipped to manage your codebase effectively using Git branches.

branch git Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

Related Posts

Make Your Git Workflow Smooth for Teams

How to Work Better with Git in Teams

Your push was rejected because it contains files larger than 10 MiB

Steps to Delete the Last Pushed Commit

How to Delete the Last Pushed Commit

Add A Comment Leave A Reply Cancel Reply Advertisement
Recent Posts
  • How to Install Python 3.14 on Ubuntu 24.04 & 22.04
  • Using loops in Terraform
  • How to Rotate Laravel Log Files
  • How to Install PHP (8.4,7.4 & 5.6) on Debian 13
  • How to Setup ERPNext v15 on Ubuntu 24.04 & 22.04
Submit

Type above and press Enter to search. Press Esc to cancel.

Manage Preferences

Tag » Add Branch Git Remote