Skip to main content

Git: Creating new branch on local machine and pushing to remote

To create a new branch from the existing branch i.e. master branch, you need to first clone the branch/repository on your local machine.

Clone a branch - 
git clone <complete-repository-url>


Creating new local branch - 
git checkout -b <branch-name> //Creates new branch on local machine with specified name.
git branch                    //List all the branches on local.

Push/Update local branch to remote - This step is very necessary as you have to update the local branch on remote as well. Your created branch will not be visible/updated to remote until running below command -
git push origin HEAD


Now you have pushed your local branch to remote. You can list all remote branches using below command -
git branch -r

Below two steps are optional.
Set upstream to local branch - Below command is used to set upstream to the newly created branch. If you do not set the upstream to your created branch, all the time you commits, you will be asked to pushed on the parent branch or your branch.
git branch --set-upstream-to=origin/<parent-branch-name> <current-branch-name>

Update your local branch - 
git pull

Hope this will help you. Suggestions are most welcome. Keep visiting my blog :)

Comments

Popular posts from this blog

app-policy

PRIVACY POLICY Last updated April 19, 2023 This privacy notice for Team CoderzDuniya ( " Company ," " we ," " us ," or " our " ), describes how and why we might collect, store, use, and/or share ( " process " ) your information when you use our services ( " Services " ), such as when you: Download and use our mobile application ( Revenue Calculator) , or any other application of ours that links to this privacy notice Engage with us in other related ways, including any sales, marketing, or events Questions or concerns?  Reading this privacy notice will help you understand your privacy rights and choices. If you do not agree with our policies and practices, please do not use our Services. If you still have any questions or concerns, please contact us at droidamar007@gmail.com . SUMMARY OF KEY POINTS This summary provides key points from our privacy notice, but you can find out more details about any of these t...

Java Socket Basics(Socket Programming in Java) Part-2(UDP)

Hi friends, We are going to discuss about UDP Socket Programming . In previous post  we discussed about the differences between TCP & UDP and the sample example of TCP Socket Programming. Below is the sample example of chat application using UDP  Socket Programming . UDP Sample :-  We are going to create an small example which contains two classes. UdpServer.java:-  This is a server class. Means this class will serve the purpose of socket connection. DatagramSocket is the java class and serve the purpose of Server and Client both. The overloaded constructor of DatagramSocket class matters. DatagramPacket is the java class which is responsible to transmit the data/packet over the network from server to client and vice-versa. UdpClient.java:-  This is client class. This serves the purpose of client which will communicate to server and send data to server and receive the data sent by server. UdpServer.java import java.net.DatagramPac...

Inline editable table-row using the edit button in Angular

In this tutorial, we will see an example of inline-editable rows of a table using mat-table. To create an  inline editable table row  using the  MatTable  component in Angular, you will need to use Angular Material ( @angular/material ) for UI components, along with Angular's built-in data binding to manage the state of each row when the user clicks the  Edit  button. Here's a step-by-step guide to implement this: Step 1: Set Up Angular Material First, you need to install Angular Material in your project. If you haven't already, run the following commands: ng add @angular/material During the installation, you will be prompted to select a theme and some other configuration options. You can choose the default options for now. Step 2: Install Required Angular Material Modules Next, you need to import the relevant Angular Material modules. Open your  app.module.ts  and import the necessary Material components: import { NgModule } from '@angular/core'...