Table Of Contents
In this post, we provide 4 fixes for a common error when you’re trying to create a Git repository.
If you’re using the Git program, there could be some instances where you’ll come across a number of errors, especially when creating a Git repository. One of these errors come in the form of this message:
fatal: not a git repository (or any of the parent directories): .git
If you’re fairly new to Git, then this might sound overwhelming for you. Fortunately, there are a few quick fixes you can follow to resolve this problem. We’ll try to tackle as many of them as possible to provide you with a working fix so you can get rid of such error.
What is the “fatal: not a git repository (or any of the parent directories): .git” Error?
The “fatal: not a git repository (or any of the parent directories): .git” error is a type of error which can come up each time you create a Git depository or try to add an existing repository to github.com. Some users reported encountering this error when entering a command and the website prompted them to put into the terminal.
There can also be instances where they’ll encounter the error when remote adding a Git repository into their local machine. In fact, there can be various causes for this error. That said, there are a few quick fixes for this.
How to Fix the “fatal: not a git repository (or any of the parent directories): .git” Error?
Resolving this specific git error can be a bit technical, but as long as you follow the steps, you’ll have a higher chance of fixing it.
1st Fix: Execute Git Init
The first fix we’re going to try is one which is provided by the Knowledge Base at Cloud Ingenium. This applies if you’re using a third-party website such as BitBucket for adding private Git repositories for free (considering that GitHub has some fees for doing so).
According to them, in order to add your repository to BitBucket, you’ll have to follow this instruction:
git remote add origin https://[email protected]/UserName/Project-Name.git
git push -u origin –all # pushes up the repo and its refs for the first time
git push -u origin –tags # pushes up any tags
Unfortunately, this resulted in the “fatal: not a git repository (or any of the parent directories): .git” error. Fortunately, this problem can be easily fixed. Here’s how:
- Start your local repository with a Git repository which is empty.
- After that, execute git init.
- Afterward, you’ll then receive this message: Initialized empty Git repository in /etc/somefolder/.git/
- Once you’re done, proceed to run a remote add origin command.
Video Guide: Copying a GitHub Repository to Your Local Computer
2nd Fix: Initialize Your Repository
This second fix is designed when you encounter the error message when pushing a repository to GitHub.com. Since the error will appear upon entering a command and the website prompts you to put the repository to the terminal, fixing the issue can be as simple as determining if you are in the right directory or not.
A user which goes by the name of jozefg at Stack Overflow recommends the following:
- Check if you’re in the right directory. You can do this by typing “ls” and checking whether it’s showing the right files or not.
- Initialize your repository. If you haven’t done it yet, simply type “git init”.
Hopefully, either one of the two can solve the fatal error message you’re encountering. If not, then proceed to the next fixes.
Video Guide: Git Tutorial For Creating Your First Repository
3rd Fix: Check the Directory or Initialize a Repository
This fix is made for individuals who are experiencing the same error when using the Heroku client package for Ruby on Rails programming. The error tends to happen when you open a new terminal and then enter this line:
git push heroku master
The issue, which was posted on Stack Overflow, comes with a few different fixes which can hopefully get rid of the error. Two of them, which are provided by users pjammer and Fiona T, involves the following:
- Making sure you’re on a git repository directory. To do this, simply type “pwd” then check if you’re in the right directory. It could be that you’re in the ~/ or another directory.
- Creating a git repository. To do so, simply use “git init” similar to that of the other fixes.
Video Guide: SignalR Tutorial 21 – Setting up a Git Repository
4th Fix: Setup Your Repository Properly
The 4th fix is from the same forum but is provided by another use by the name of Prakash Murthy. According to him, the error message could possibly be due to an improper git init setup. He recommends making sure that you’ve followed all the instructions with regards to the installation and setup of Git in your system. Here’s how:
- If it’s your first-time setup, you’ll have to do some one-time setups first. These include entering the following lines: $ git config –global user.name “Your Name” and $ git config –global user.email [email protected]. Keep in mind that the name and email address which you use will also be available in any public repositories you make.
- After that, the next step is to set up your repository. What you should do is to navigate to the root directory of your first app then execute the following lines:
$ git init
Initialized empty Git repository in
- Once you’re done, add your files to your repository using this line: $ git add –A. This line will add all files in your current directory except for those that have matched the patterns in the .gitignore file. This file will automatically be created with the Rails new command with regards to a Rails Project. However, you also have the option to add new patterns.
- Your files when then be stored in a staging area waiting for a confirmation. To check your files, you can use the $ git status command. If you want to commit the changes, simply use the “commit” command.
Hopefully, by properly setting up Git in your system, you’ll be able to get rid of the problem for good.
To understand more about the problem computer screen sideways, we read through different support boards. People were interested in knowing about how to fix a computer screen sideways, and computer screen sideways fix on Windows 10 and Windows 7. Some were also looking for answers on computer screen sideways Chromebook, HP, and Lenovo.
- A computer user complained that his screen got turned sideways while he was working on it.
- The person wasn’t computer savvy and was wondering how to fix the problem. He attempted to do it from Properties but didn’t have much success.
- Finally, he asked for help online, and another computer expert explained that he must have press some keys accidentally to change the position of the screen.
- To solve the problem, the person said that he had to press Ctrl + Alt + UP Arrow Key and that it should fix his screen.
- However, he warned that the solution might not work for Windows 10.
Another person also mentioned that he had a similar problem with his old Windows XP computer and that he looked for a solution online. People suggested that he tried the Ctrl + Alt + an arrow key until he found the correct screen position.
A computer expert explains that if you can’t turn your screen using Ctrl + Alt + Arrow Key, you can try the graphics option because the rotation of the screen is a feature of your graphics card.
- The user states that you if you use Windows 10, you should click on the empty desktop, choose Display Settings and select the right orientation from the Orientation drop-down menu.
- If you’re still using Windows 7 and Windows 8, you should choose Control Panel > Appearance and Personalization > Adjust screen resolution > Orientation.
- Another individual commented that if you couldn’t fix your sideway computer screen, you might try to restore the system to a previous point.
- However, he pointed out that it’s a last resort measure and the problem would rarely be so serious as to require a system restore.
A person observes that your screen might have turned sideways because you have a problem with your graphics card if you’re certain that you haven’t pressed anything.
- In such cases, he recommends that you update your graphics cards drivers.
- The update will take care of any missing or corrupted files and should resolve your screen troubles.
Another person pointed out that you can restore your screen by clicking on the desktop and choosing Graphics Options.
- He also mentioned that if the Ctrl + Alt + UP command is not working your hotkeys might have been disabled.
A forum member complained that since he installed Windows 10, his screen started to turn sideways from time to time. He was able to fix it with the Ctrl + Alt + Arrow Key, however, it kept happening every time he would open a new application.
- The user went looking for a solution online, but he was unable to find one.
- The only thing that support suggested was to run the commands for corrupted files, which didn’t yield any result.
- He concluded that if the problem persisted, he would opt to uninstall Windows 10 and go back to Windows 8.1.
Another Windows 10 user also shared that he had to change the orientation of his screen several times after a major Windows update. The person was certain that he had saved his preferences to landscape orientation, but his device kept turning it back to portrait. Finally, he noticed in the settings that his device was set to tablet. After he turned it off, the problem disappeared.
Another person mentioned that he was experiencing the same Windows 10 problem and that the Ctrl + Alt + Arrow Key command wasn’t working for him. So, he reached out to support, and they suggested that he should roll back or uninstall the drivers of the display device. Support also said that he could try to update his graphics drivers from the official page of the manufacturer.
A user said that the screen on his Chromebook suddenly turned sideways. He was cleaning the keyboard, so he supposed that he had pressed the wrong buttons. Other forum members explained that he could rotate the screen by pressing Cntl+Shift+circular arrow, which would rotate the screen 90 degrees. The added that he should continue to press the buttons until the screen was back in its original position.
The “fatal: not a git repository (or any of the parent directories): .git” error is quite a technical error requiring a bit of technical and programming knowledge. However, if you already know how to work your way around Git, you should be able to resolve this issue using the above fixes.
Ryan is a computer enthusiast who has a knack for fixing difficult and technical software problems. Whether you’re having issues with Windows, Safari, Chrome or even an HP printer, Ryan helps out by figuring out easy solutions to common error codes.