https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/attachment/7230109/3056274/
I am having the same problem as this guy, I was wondering how to track hidden files and their contents so that they can be committed. Github seems to be globally blocking and ignoring my files (no matter which repo) when I try and drag and drop my files into it.
The problem started after I committed folders named lab1, lab2, lab3 through command line. I then later decided to remove them used
git rm -r lab1/ lab2/ lab3/
Now when I try to add all of the folders back to git, they are «detectless» and do not show up on git status
, when I git add
them
from my local folder even with changes to my gitignore
file.
rkta
3,6867 gold badges27 silver badges36 bronze badges
asked Jul 4, 2018 at 23:39
2
First, you can check if this is a .gitignore issue by typing, from the root folder of your repo:
git check-ignore -v -- lab1/a_File_In_Lab1
Second, Make sure Lab1 does not have a .git subfolder in it: that would make it a nested repository, and you would need a git rm --cached Lab1
(no trailing slash) to remove the gitlink recorded in your main repo.
answered Jul 5, 2018 at 4:37
VonCVonC
1.2m508 gold badges4248 silver badges5069 bronze badges
As a quick workaround, you may want to use ‘Create new file’ option on GitHub.
I am having the same issue, but as the number of «hidden» files is manageable, I am simply «creating» the files on GitHub and Copy-Pasting the content inside of them.
This is obviously not a reliable solution we might prefer, but for now, it works!
answered Nov 24, 2019 at 7:12
Mihir JoshiMihir Joshi
4065 silver badges14 bronze badges
Как добавить скрытые файлы, например, .flake8, в git? Git add. не работает и даже подкаталоги не добавляются. Проблема не в Gitignore. Спасибо.
2
Pyjs
6 Авг 2019 в 13:34
–
Frank Hopkins
6 Авг 2019 в 13:40
2 ответа
Ничего особенного, просто
git add .flake8
PS. git add .
тоже должен работать. Каким образом это у вас не работает?
1
Git add. не добавляет .flake8 и подкаталоги. Я проверяю .gitignore, и проблема не в этом. Я пробовал git add .flake8, и он не добавляет .flake8 после проверки с помощью git status.
–
Pyjs
6 Авг 2019 в 13:40
Это странно. Ну, точка .
означает «текущий каталог»; убедитесь, что текущий каталог является корнем репо при запуске git add .
–
phd
6 Авг 2019 в 13:43
Git rev-parse —show-toplevel проверяет, что я получил правильный корневой каталог. То же, что и pwd, за исключением того, что pwd не добавляет: в c, как c: в ОС Windows.
–
Pyjs
6 Авг 2019 в 13:55
Это то же самое, что и pwd
?
–
phd
6 Авг 2019 в 13:55
Похожие вопросы
Связанные вопросы
Новые вопросы
git
Git — это распределенная система контроля версий с открытым исходным кодом (DVCS). Используйте этот тег для вопросов об использовании Git и рабочих процессах. Не используйте этот тег для общих вопросов по программированию, связанных с репозиторием Git. Не используйте этот тег для вопросов GitHub/GitHub Actions, не связанных с использованием git; вместо этого используйте [github] или [github-actions]. Не используйте тег [github] для проблем, связанных с Git, только потому, что репозиторий размещен на GitHub.
Подробнее про git…
The simplest way : start a terminal using git-bash
, or from WSL (Windows Subsystem for Linux).
You will have a bash
shell with access to the standard linux utilies, and ls -la
should work from such terminals.
If you started a Powershell terminal, try ls -Hidden
.
ls
is actually an alias to the powershell command : Get-ChildItem
.
The Powershell team mapped a number of usual linux command names to Powershell built-ins (e.g : cd
-> Set-Location
, uniq
-> Get-Unique
, pushd
-> Push-Location
, … ), but didn’t map the options, so the options expected by ls
in a Powershell terminal aren’t -a
… but rather the options to Get-ChildItem
.
One way to figure out what’s expected from a «linux» command name you know is to type : get-help <command name>
you will see the actual powershell command name, and the options it expects, for example :
$ get-help ls
NAME
Get-ChildItem
SUMMARY
Gets the items and child items in one or more specified locations.
SYNTAX
Get-ChildItem [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device | Directory | Encrypted |
Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly | ReparsePoint |
SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude <System.String[]>] [-File]
[-Force] [-Hidden] [-Include <System.String[]>] -LiteralPath <System.String[]> [-Name] [-ReadOnly] [-Recurse]
[-System] [-UseTransaction] [<CommonParameters>]
Get-ChildItem [[-Path] <System.String[]>] [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device
| Directory | Encrypted | Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly
| ReparsePoint | SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude
<System.String[]>] [-File] [-Force] [-Hidden] [-Include <System.String[]>] [-Name] [-ReadOnly] [-Recurse]
[-System] [-UseTransaction] [<CommonParameters>]
DESCRIPTION
The `Get-ChildItem` cmdlet gets the items in one or more specified locations. [...]
The simplest way : start a terminal using git-bash
, or from WSL (Windows Subsystem for Linux).
You will have a bash
shell with access to the standard linux utilies, and ls -la
should work from such terminals.
If you started a Powershell terminal, try ls -Hidden
.
ls
is actually an alias to the powershell command : Get-ChildItem
.
The Powershell team mapped a number of usual linux command names to Powershell built-ins (e.g : cd
-> Set-Location
, uniq
-> Get-Unique
, pushd
-> Push-Location
, … ), but didn’t map the options, so the options expected by ls
in a Powershell terminal aren’t -a
… but rather the options to Get-ChildItem
.
One way to figure out what’s expected from a «linux» command name you know is to type : get-help <command name>
you will see the actual powershell command name, and the options it expects, for example :
$ get-help ls
NAME
Get-ChildItem
SUMMARY
Gets the items and child items in one or more specified locations.
SYNTAX
Get-ChildItem [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device | Directory | Encrypted |
Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly | ReparsePoint |
SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude <System.String[]>] [-File]
[-Force] [-Hidden] [-Include <System.String[]>] -LiteralPath <System.String[]> [-Name] [-ReadOnly] [-Recurse]
[-System] [-UseTransaction] [<CommonParameters>]
Get-ChildItem [[-Path] <System.String[]>] [[-Filter] <System.String>] [-Attributes {Archive | Compressed | Device
| Directory | Encrypted | Hidden | IntegrityStream | Normal | NoScrubData | NotContentIndexed | Offline | ReadOnly
| ReparsePoint | SparseFile | System | Temporary}] [-Depth <System.UInt32>] [-Directory] [-Exclude
<System.String[]>] [-File] [-Force] [-Hidden] [-Include <System.String[]>] [-Name] [-ReadOnly] [-Recurse]
[-System] [-UseTransaction] [<CommonParameters>]
DESCRIPTION
The `Get-ChildItem` cmdlet gets the items in one or more specified locations. [...]
Before you can read from a private repository or write to a Git repository, you must be authenticated. If you use the wrong Uniform Resource Locator (URL) to connect to a repository, or have incorrectly set up your Secure Shell (SSH) authentication, you’ll encounter the “fatal: Could not read from remote repository” error.
This guide discusses what this error means and why you may see it. It walks you through two potential solutions so you can overcome this problem when using Git.
Find Your Bootcamp Match
- Career Karma matches you with top tech bootcamps
- Access exclusive scholarships and prep courses
Select your interest
First name
Last name
Phone number
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.
fatal: Could not read from remote repository
SSH is a protocol for authenticating with remote devices. SSH is commonly used to authenticate with Git because you don’t need to type in your password every time you authenticate.
Every platform has its own way of authenticating users over SSH. Using GitHub, for instance, you must provide your SSH key on their dashboard. Then, you can use the SSH URL associated with your repository to authenticate with GitHub.
By default, the private SSH key for your device will be in a file called ~/.ssh/id_rsa. This file is in the hidden .ssh directory in your root folder. This key will only exist if you have generated it. Otherwise, you’ll need to use the ssh-keygen command to generate a new key.
If you have not correctly set up SSH authentication, Git will be unable to verify your identity.
The two common causes to the “fatal: Could not read from remote repository” error are:
- Not adding your SSH key to the SSH agent
- Using a HTTP URL to connect to a repository
Let’s discuss each of these causes.
Cause #1: SSH Agent Issue
The SSH agent stores your SSH key. When you try to authenticate with a Git repository over SSH, Git will check the SSH agent for your key.
Your SSH key can be removed from the SSH agent for various reasons. This will make it impossible to authenticate with a Git repository.
Let’s try to clone a Git repository that is private to our local machine:
git clone git@github.com:career-karma-tutorials/ck-git
When we try to sign in, the Git command line returns an error:
fatal: Could not read from remote repository.
This error informs us we have an authentication issue. If you encounter an SSH authentication issue, your first port of call is to add your key to the SSH keychain:
This will add our id_rsa key to the keychain.
Another common mistake is to add the wrong key to your keychain. If you use a key with a different name than id_rsa to authenticate with Git, make sure you add that key to your keychain and not the id_rsa key.
Cause #2: Using a HTTP URL
There are two ways you can authenticate with Git: over HTTP and SSH. The Hypertext Transfer Protocol (HTTP) method requires specifying your username and password to a Git server to access a repository.
To authenticate with HTTP, you’ll use a URL that looks like this:
https://github.com/career-karma-tutorials/ck-git
You cannot use this URL to connect to a Git server over SSH. This is because SSH and HTTP are different protocols. If you try to sign in to the above URL using SSH, you’ll be prompted to enter your username and password.
We’ve got to use an SSH URL to connect to a repository over SSH. You can verify the URLs that you use to connect to a remote repository using the git remote -v command:
origin https://github.com/career-karma-tutorials/ck-git (fetch) origin https://github.com/career-karma-tutorials/ck-git (push)
We can see that our “origin” remote uses HTTP instead of SSH. For an existing repository, we can change our URL to use SSH using the git remote set-url command:
git remote set-url origin git@github.com:career-karma-tutorials/ck-git
This command sets the “origin” URL to be equal to our SSH URL. Now that we’ve run this command, our existing Git repository will use the SSH URL to connect to the remote version of the repository.
If you are cloning a new repository, you don’t need to change the URL with which you are working. Instead, you just need to make sure you use an SSH URL to clone the repo:
git clone git@github.com:career-karma-tutorials/ck-git
Now, we can run commands like git pull, git commit, and git push on our repository because we have the correct access privileges.
Conclusion
The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication.
To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.