| by Arround The Web | No comments

What does “git push origin HEAD” mean

On Git, users perform several tasks, like creating new branches, tags, fetching, pulling, and pushing source code files to update the GitHub repository. Additionally, to perform these operations, developers need to stay connected to the local and remote branches through cloning. After that, they can push a local working branch to the remote with the same name.

This guide will illustrate the method to push the local branch into the remote with the same name branch.

How to Push Local Branch Into Remote With Same Name?

Follow the below-listed instructions to push the local branch into the remote branch with the same name:

    • Go to the Git working branch.
    • Generate and track a new file into the repository.
    • Save changes by committing.
    • Run the “$ git push <remote-name> HEAD” command.

So, move ahead and understand by performing practically!

Step 1: Navigate to Git Working Repository

Run the given command to go to the Git working directory:

$ cd "C:\Users\nazma\Git\Test_12"

 

Step 2: Generate Text File

Then, make a new file in the working directory through the “touch” command:

$ touch file2.txt

 

Step 3: Push File to Staging Area

Now, run the “git add” command to push a newly created text file into the staging index:

$ git add file2.txt

 

Step 4: Save Changes Into Git Repository

After that, save all added changes into the working repository by executing the “git commit” command:

$ git commit -m "2nd file added"

 

Step 5: Push Current Branch Into Remote Repository

Lastly, run the “git push” command along with the remote name and “HEAD” to push the current working local branch to the same name on the remote:

$ git push origin HEAD

 
According to the below-provided output, the specified local branch is pushed into the same name remote branch:


We have explained the method to push the local branch into the remote with the same name branch.

Conclusion

To push the local branch into the remote branch with the same name, first, run the “cd” command to move to the working repository, create and track a new file into the repository. Then, update the repository by committing added changes and run the “$ git push <remote-name> HEAD” command. This guide discussed the procedure to push the local branch into the remote with the same name branch.

Share Button

Source: linuxhint.com

Leave a Reply