This post will briefly discuss the “git push origin master” command.
Why “git push origin master” Does Not Work?
Sometimes, Git users get a fatal error while pushing the local content into the GitHub server because the remote URL is not specified. To add it, the “git remote add <remote-name> <remote-url>” command can be used.
In the below-provided steps, first, we will demonstrate how the “fatal:….” error encounters and then resolve it.
Step 1: Switch to Git Repository
Initially, type out the “cd” command and navigate to the Git local repository:
Step 2: Generate File
To create a new file in the repository, run the “touch” command:
Step 3: Push File to Git Index
Then, execute the “git add” command to add a file into the staging index:
Step 4: Commit Changes
Next, update the repository by committing all added changes through the “git commit” command:
Step 5: Push Local Content
Execute the provided command and specify the remote and branch name:
As you can see, the above command gives a “fatal: ‘origin’ does not…….” error after executing it:
Note: Check out the following steps to resolve the above-listed error.
Step 6: Check Remote URL List
Then, check the remote URL list by utilizing the given command:
According to the below-provided output, the remote URL is not specified that we previously used for pushing the local content:
Step 7: Add Remote URL
Add the remote URL to the list by running the following command:
Step 8: Push Local Changes
Finally, execute the “git push” command to push the local repository data into the centralized server:
As you can see, we have successfully pushed the local content into the remote repository:
That’s all about resolving the “git push origin master” command not working issue.
The “git remote origin master” does not work when the remote URL is not specified. To resolve this issue, use the “git remote add <remote-name> <remote-url>” command. Then, run the “git push <remote-name> <branch>” command to push the local content. This post described the issues that occur while executing the “git push origin master” does not work.