| by Arround The Web | No comments

Git origin master

On Git, to perform git fetch and git push with other project members, the “origin” and “master” repositories can be utilized. origin and master are two different terms used while working on and managing Git projects. More specifically, the origin is the default name assigned to a Git remote repository; however, the master is a Git branch name.

This blog will discuss the Git origin master branch.

How to Switch, Fetch and Push Origin Master?

To switch branches, fetch and push the local branch to remote; firstly, move to the Git root directory and create a new repository. Then, clone the repository and view the remote origin or list of the remote connections by executing the “$ git remote -v” command. Next, switch to the required branch.

Let’s move ahead and practically perform the above-specified procedure!

Step 1: Move to Git Root Directory

First, move to the Git root directory using the “cd” command:

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

Step 2: Create Repository

Run the “mkdir” command to create a new repository:

$ mkdir Demo1

Step 3: Clone Repository

Clone the remote repository by utilizing the “git clone” command and specify the URL of the remote repository:

$ git clone https://github.com/GitUser0422/demo3.git

Step 4: Check Remote Origin

Run the “git remote” command to view the remote origin:

$ git remote -v

The given output displays the list of remote connections:

Step 5: Switch Branch

Next, switch to the master branch by utilizing the provided command:

$ git switch master

Step 6: Fetch Branch

Now, download the remote master branch to the local repository using the “git fetch” command:

$ git merge origin/master

Step 7: Merge Remote Branch

Execute the “git merge” command to merge the local branch to the remote branch:

$ git merge origin/master --allow-unrelated-histories

Step 8: Execute git push Command

Now, push the updated master branch to the remote repository through the following command:

$ git push origin master

We have explained about Git origin master with an example.

Conclusion

In Git, origin and master are two different terms. The origin is the default name assigned to a Git remote repository; however, the master is a Git branch name. To view the remote origin, execute the “$ git remote -v” command. Moreover, the “$ git checkout <branch-name>” command can be utilized to switch from one branch to another branch. This blog discussed Git origin master.

Share Button

Source: linuxhint.com

Leave a Reply