error pathspec did not match any file s known to git что делать
I am using a local git repo. When I try to commit changes to the core data model file (.xcdatamodel), I get this message:
How to fix this and commit the model as I do with any other file?
15 Answers 15
The problem is, indeed, the changing of a filename’s case. For me this was because of my Macbook/OSX. Apparently Windows has the same ‘thing’.
Cause: git isn’t able to recognise a change from ‘filename’ to ‘FileName’.
Here’s a list of solutions for anyone stumbling upon this. All the solutions should be run at the project root:
The Permanent fix that will work on current and future projects
Change the git case setting. The file should be committed afterwards
The Project only fix
The I get paid by the hour fix
Based on your needs you may want to revert the settings. Do:
I solved the problem simply by closing XCODE and opening it again. I know it is not a cool solution, but it worked without any changes to any files on my part.
This is not a proper way to solve the problem, but it’s a workaround that may help others. Do this in your terminal:
Replace with your message, and with the directory of your project.
Git doesn’t like renames where the source and destination differ only by case. (Windows-specific) See How do I commit case-sensitive only filename changes in Git? for solutions.
This is similar to tf.alves answer, but normally I do a
I got the same error using xcode 9.1. I solved it by manual commit from the terminal. The steps are as follows
Once you manually commit all the changes successfully from the terminal, then you can use source control in xcode.
I got this error in Xcode, just restarted Xcode and then commited again.
Not sure but I think it could be that git was holding reference to the old file name and cleaning the build folder and building again corrected that.
Я не уверен, почему я не могу оформить заказ на ветку, над которой работал раньше. Смотрите команды ниже (примечание: co это псевдоним для checkout ):
Я не уверен, что это значит, и я не могу найти ничего, что я могу понять в Google.
Как мне оформить эту ветку и что я мог сделать, чтобы сломать это?
ОБНОВЛЕНИЕ :
ОБНОВЛЕНИЕ на git show 3af84fcf1508c44013844dcd0998a14e61455034
Попробуйте, git fetch чтобы ваш локальный репозиторий получал всю новую информацию от github. Он просто берет информацию о новых ветвях и не содержит фактического кода. После этого git checkout должно работать нормально.
Я получал эту ошибку, когда пытался оформить заказ на новую ветку:
ошибка: pathspec ‘BRANCH-NAME’ не соответствует ни одному из файлов, известных git.
Когда я попытался git checkout origin/
, я получил отдельную ГОЛОВУ:
Наконец, я сделал следующее, чтобы решить проблему :
Я получил эту ошибку для ветви, которая была удаленной и не имела локальной ветви отслеживания. Хотя я уверен, что проверил удаленные ветви с помощью простого
в прошлом, чтобы обойти эту ошибку, мне пришлось
Я понятия не имею, что я сделал, чтобы попасть в эту ситуацию.
У меня есть те же вопросы, и я получил некоторую информацию по этой ссылке: git fetch не выбирает все ветки
Поэтому сейчас я не уверен, как эта ситуация произошла, по крайней мере, мы можем ее решить:
Шаг 1. Проверьте настройки «remote.origin.fetch», должно быть так
+ Ссылки / главы / private_dev_branch: ссылки / пультов ДУ / происхождение / private_dev_branch
Шаг 2. Измените «remote.origin.fetch», чтобы получить все
$ git config remote.origin.fetch «+ refs / heads / *: refs / remotes / origin / *»
+ Ссылки / главы / *: ссылки / пультов ДУ / происхождение / *
Затем вы можете попробовать «git pull» (возможно, «git fetch origin» также работает, но я не пытался), чтобы получить всю ветку.
это не то же самое, что
Если в имени ветви нет незафиксированного файла, попробуйте
Я столкнулся с проблемой при переключении моей ветви.
Я сделал git pull на текущую ветку, а затем попытался проверить новую, и это сработало
git pull // on your old branch git checkout
Это просто исправило это для меня 🙂
У законченного git clone будет все исправлено.
Я получил это, когда я сделал следующее:
Когда я попытался проверить в каталоге, я получил эту ошибку.
Я открыл репо в расширениях git. Я видел, что файл (со старым именем) был поставлен. Но поскольку его больше не было, его нельзя было совершить.
Я просто unstaged этот файл.
Затем я повторно добавил файл (на этот раз правильно названный) в git и зафиксировал без ошибок.
У меня была эта проблема сегодня я пытался git checkout foo и получил error: pathspec ‘foo’ did not match any file(s) known to git.
Я получил эту ошибку при попытке оформить ветку через:
который я не проверил раньше. Это работало только при явном указании удаленного:
Причиной этого было то, что у меня было 2 разных пульта (origin + sth. Else), настроенных в git config. Поскольку мне не нужен второй пульт, я снял его и вуаля, он работал. Альтернатива для установки удаленного по умолчанию через:
у меня не сработало
Во-первых, проверьте родительскую ветвь. Затем введите
Я исправил, изменив его
Обратите внимание, что заголовок указывает только на одну ветку, поэтому он не может найти ссылку на другие существующие ветви, я изменил ее на *, чтобы она проверяла все в источнике.
В ОС Windows по умолчанию git устанавливается с
Это означает, что файлы git repo будут нечувствительны к регистру, чтобы изменить это, вам нужно выполнить:
Вы можете найти эту конфигурацию в файле .git \ config
Исправлено добавление вышеуказанной строки error: pathspec ‘master’ did not match any file(s) known to git.
Тогда я попробовал полное название ветки:
тогда работал на меня.
Если это происходит в Windows, это, вероятно, проблема с именем файла.
В моем случае у меня есть ДВА ветки 1) master (для живого сервера) 2) dev (тестовый сервер). Я установил несколько пультов для отправки кода на соответствующий сервер. Когда я попытался переключить ветку, я получил ошибку, как error: pathspec ‘master’ did not match any file(s) known to git.
Теперь я могу оформить заказ в филиале git checkout
.
Я подумал, что мог запутать git, используя ключевое слово в сообщении фиксации, поэтому я попробовал несколько других слов и получил ту же ошибку.
У меня была другая причина
У меня был сценарий, который в основном ищет во всех ветвях, соответствующих ключу выпуска jira для «PRJ-1234» среди всех ветвей, чтобы выполнить команду проверки ветки git в соответствующей ветке
Проблема в моем случае заключалась в том, что 2 или более веток использовали один и тот же ключ jira и, следовательно, приводили к сбою моего скрипта с вышеупомянутой ошибкой
Удалив старую неиспользуемую ветвь и убедившись, что ссылка на ключ jira была исправлена только в одной ветке
Вот мой код на случай, если кто-то захочет его использовать
сохранить это как switchbranch.sh
Ни один из этих ответов не решил мою проблему:
Как показано выше, для частичных хеш-кодов вы должны указать внешний интерфейс, а не внутренний.
Произошло со мной после переименования незафиксированного файла в Android Studio.
У Git, похоже, была старая версия в своем хранилище, даже если ее больше не существовало.
Поэтому я открыл графический интерфейс Git TortoiseGit, который показал мне точный файл, вызвавший проблемы.
После этого я удалил файл из хранилища с помощью
и проблема исчезла
Я думаю, что это было связано с проблемой. Выполнение git fetch не решило проблему.
Я переместил файлы из моего проекта, сделал выборку и сделал push без них. Затем я сделал выборку, добавил их обратно и сделал толчок, и это сработало. Я не знаю, были ли все эти шаги необходимы, но в конечном итоге это сработало.
в моем случае я вхожу в подмодульную директорию без
Так что git был связан с родительской папкой, которая действительно пропустила эту ветку.
проверьте, не является ли это опечаткой в имени целевого файла. Я пытался поставить, набрав
Но я не заметил, что я использовал две точки, но потом я печатаю
Для меня это была проблема с моими полномочиями
Попробовав некоторые ответы, один из них помог мне решить проблему:
Запуск git fetch выкинул следующую ошибку:
Не удалось разрешить хост: bitbucket.org
Все, что мне нужно было сделать, это заставить мою IDE (VS Code в моем случае) запомнить мои учетные данные:
Git сразу синхронизировал все изменения и git checkout
теперь работает нормально!
error: pathspec ‘. ‘ did not match any file(s) known to git
I’m calling git checkout HEAD
2 «Finished 1 stage» (or just git checkout «Finished 1 stage» )
Then i get error: pathspec ‘Finished 1 stage’ did not match any file(s) known to git
I’m trying to get files from commit «Finished 1 stage»
I hope you will help me!
2 Answers 2
I’m trying to get files from commit «Finished 1 stage»
In Git, commits are numbered, as a big long ugly hexadecimal number. What git checkout or git restore actually needs here is the commit’s number. So at the raw level you might write:
This means switch to that (entire) commit (as a «detached HEAD»); your working tree will then consist of files from that commit, plus any untracked files that Git does not touch, that remain in place from before. 1
If you only want some particular files from that particular commit, the best—as in safest—way to express that is:
2 is a way to avoid having to type in the hash ID.
2 names that commit—which it might—then HEAD
2 is all you need and is all you should enter. The commit’s subject text, such as «Finished 1 stage», should not be included here.
To see the hash ID from HEAD
(your results will differ). To get a better look at the commit, consider using git show :
(output not included here).
There are ways to use the log messages to search for a commit. These are described in the gitrevisions documentation, which is worth repeated reading over time. But if HEAD
2 suffices, you should probably just use that.
1 There is a special case for files that you have modified but not yet committed. For the gory details, see Checkout another branch when there are uncommitted changes on the current branch.
error: pathspec ‘. ‘ did not match any file(s) known to git #6
Comments
Dauflo commented Sep 19, 2019 •
I was trying your github action for a personnal project and end up with that stack trace
I searched a bit for this error, and it seems that maybe git does not know the branch i’m trying to checkout (https://stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn)
I think the trick is maybe to add git fetch to your entrypoint.sh to be sure git know all the branches
The text was updated successfully, but these errors were encountered:
stefanzweifel commented Sep 19, 2019
That might be a good idea, yeah. Would it be possible for you, to fork this project, make the change in entrypoint.sh and use it with your Action?
You would have to update your code to:
This might also be related to actions/checkout#6. Most of the problems with this action are related to how GitHub checkouts the code.
TingluoHuang commented Sep 20, 2019
error: pathspec ‘2/merge’ did not match any file(s) known to git means you are on a PR merge ref. What behavior do you want when your action running in a PR run? @stefanzweifel
stefanzweifel commented Sep 20, 2019
@TingluoHuang The action should just commit and push changes back to the branch, where the action is being run on. If it’s a PR from another person, the changes should be pushed back to their repo (if this is even possible).
I’ve followed the discussion in actions/checkout#6, as I too had issues where the repo was in a detached state and therefore couldn’t commit back to the repo.
I’ve used git checkout «$
Will try this approach over the next few days to get to checkout the right branch https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh#L48
Dauflo commented Sep 20, 2019 •
stefanzweifel commented Sep 20, 2019
Yeah I see that too. Wanted to use my own action in a project and ran in the same problem.
I’m trying to get it working again on a branch. Here’s the current state of the entrypoint.sh file.
https://github.com/stefanzweifel/git-auto-commit-action/blob/fix-branch-checkout/entrypoint.sh
Will come back to this issue, when I got a working solution.
stefanzweifel commented Sep 20, 2019
Good news, I got it working again!
@Dauflo would it be possible for you to try this action in your project like this?
I will tag a version in the next couple of days.
Dauflo commented Sep 20, 2019
If you want the logs just in case :
stefanzweifel commented Sep 20, 2019
Thanks for the quick feedback. Will tag a new stable release very soon.
stefanzweifel commented Sep 20, 2019
v2.1.0 has been tagged. Going to close this issue now.
I am having some issues with Git.
I have a repository where I can commit any file to without problem. However, there is a single file ‘Funder.php’ which, when I try committing, tells me there is an error as:
I am quite new to this, so was wondering if anybody could please help?
20 Answers 20
The reason why this error happens is pointed in this post: https://stackoverflow.com/a/29485441/2769415
Windows’ file system is mostly case-insensitive, so you cannot rename a file by just changing its capitalization. Instead, you will have to use a temporary name in between.
Solution: Rename the file back to the original one, then rename it to a different name, then back to the one with the correct capitalization. Git will not throw the bug anymore.
This is the error you get when you attempt to run
but hasn’t been staged yet; in other words, Git hasn’t been told about it, yet. This is most likely what’s happening here. Run
then try to commit.
I had the same problem in Android Studio after renaming some activities. I tried adding (git add) and moving (git mv) the files but never helped and I was getting the same message again and again.
Finally I decided to backup the classes in the package that had the problematic file in a separate folder in my HDD, then I removed the files from the original folder and in the terminal I did:
Then recreated the deleted package via Android Studio and copied and pasted my classes back there. After that I was able to commit without any issues.
Here’s a concise answer on the quickest way to resolve this issue. Similar to @cmbind55 post but to the point.
Problem: I have added a file that I later renamed.
Solution:
git reset HEAD oldFileName.file
git add newFileName.file
if working from terminal ensure that you have a message flag in your command.
git commit «Your Commit Message» //Throws an error: pathspec ‘3.
I had this failing commit scenario due to a renamed directory.
This was the originally created directory with a capitalization mistake:
Within the IDE, I had agreed to add this file to the existing git repo. In later testing, I discovered I had a case-sensitive path issue with the capitalization of «Templates». Within the IDE, I simply renamed the directory to «templates» (changed to lower-case). I did not record the actual sequence of events around this, but later when my commit failed with the following message, I had a hunch this was this issue. Apparently, the IDE did not fully handle this case of renaming a directory.
The IDE commit error message:
Commit failed with error: pathspec «application/templates/lists/index.html» did not match any file(s) known to git.
After doing some reading, my strategy was to take the file back out and then add it again. I unstaged the suspect file
Note, git status only showed the directory here. Not the file.
Then, I added back with the corrected directory name (I only used the path for the add, following the lead from git status).
After this, my commit succeeded. I’m not sure if this was the ideal technique, but it resolved the commit error in my case.