When developers add changes in the local repository and push them to the GitHub hosting service without any tracking remote URL, they often face the “fatal: ‘origin’ does not appear to be a git repository” error. To resolve this issue, it is required to add the tracking remote URL through the “$ git remote add origin <remote-url>” command.
This post will discuss:
- When the “fatal: ‘origin’ does not appear to be a git repository” Error Occurs?
- How to Fix “fatal: ‘origin’ does not appear to be a git repository” Error?
When the “fatal: ‘origin’ does not appear to be a git repository” Error Occurs?
The above-listed error often occurs when the user wants to push the local changes into the remote repository without adding the remote URL for tracking. For a better understanding, first, we will show the above-discussed error and then provide the method to resolve it.
Step 1: Move to Repository
First, navigate to the Git desired repository through the provided command:
Step 2: Create File
Next, run the “touch” command to create a new file in the repository:
Step 3: Track Newly Created File
Now, track the newly created file to the staging area by using the following command:
Step 4: Commit Changes
Execute the “git commit” command to commit the added changes into the repository:
Step 5: Check Git Log History
Next, check the Git repository log history using the stated command:
Step 6: Git Push
Next, run the “git push” command with the remote name and local branch:
As you can see, the above-listed command gives an error:
Let’s check out the next section to solve the encountered error.
How to Fix “fatal: ‘origin’ does not appear to be a git repository” Error?
To solve the above-encountered error, follow the below-given instructions.
Step 1: Check Remote List
First, check the list of remote URLs by utilizing the “git remote” command:
According to the below-provided output, no remote URL currently exists:
Step 2: Copy Remote URL
Open GitHub, select the repository and copy its HTTPS URL:
Step 3: Add Remote URL
Execute the “git remote add” command with the remote name and copied the remote URL to add it:
Step 4: Pull Local Branch
Finally, execute the “git pull” command with the “–allow-unrelated-histories” option to pull the local branch:
As a result, Git will open the merge message file in the default text editor. In this file, add a comment and save it:
As you can see, the pull operation is performed successfully, and the previously encountered error is resolved:
That’s all! We have provided the solution to fix the fatal error that occurred while pushing the local branch into the remote.
Conclusion
The discussed fatal error often occurs when the user pushes the local changes into the remote repository without adding the tracking remote URL. To solve this issue, execute the “$ git remote add origin <remote-url>” command to add a new remote URL. This post provided the solution to solve the fatal error that often occur while pushing the local change into the remote repository.