Score:0

How do I handle git asking me to remove untouched files?

lu flag

A while ago, I cloned the Drupal repo. Today, I attempted a pull only to find out that I'm being asked to remove most, if not all, of the core directory to prevent overwriting. This happened to me once again about a month ago and I fixed it by removing the core directory prior to pulling, but obviously I can't remove the directory every time I pull. How can I fix this once and for all?

EDIT: git output:

➜  dev-drupal git:(10.1.x) ✗ time gl
remote: Enumerating objects: 28, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 28 (delta 8), reused 17 (delta 8), pack-reused 3
Unpacking objects: 100% (28/28), 29.22 KiB | 1.33 MiB/s, done.
From https://git.drupalcode.org/project/drupal
   d3d1d05dfa..3c8128a0ac  11.x       -> origin/11.x
Updating 2090b606ea..65212de44c
error: Your local changes to the following files would be overwritten by merge:
    composer.json
    composer.lock
    composer/Generator/Builder/DrupalCoreRecommendedBuilder.php
    composer/Metapackage/CoreRecommended/composer.json
    composer/Metapackage/DevDependencies/composer.json
    composer/Metapackage/PinnedDevDependencies/composer.json
    core/MAINTAINERS.txt
    core/assets/scaffold/files/default.settings.php
    core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ar.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ast.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/az.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/bg.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/bn.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ca.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/cs.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/da.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/de-ch.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/de.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/el.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/en-au.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/en-gb.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/eo.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/es.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/et.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/eu.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/fa.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/fi.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/fr.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/gl.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/he.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/hi.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/hr.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/hu.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/id.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/it.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ja.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/km.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/kn.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ko.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ku.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/lt.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/lv.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ms.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/nb.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ne.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/nl.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/no.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/pl.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/pt-br.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/pt.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ro.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ru.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sk.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sl.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sq.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sr-latn.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sr.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/sv.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/th.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/tk.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/tr.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/tt.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ug.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/uk.js
    core/assets/vendor/ckeditor5/ckeditor5-dll/translations/ur.js
    core/assets/vendor/c
error: The following untracked working tree files would be overwritten by merge:
    core/assets/vendor/ckeditor5/horizontal-line/translations/uz.js
    core/assets/vendor/ckeditor5/special-characters/translations/hr.js
    core/assets/vendor/ckeditor5/table/translations/sl.js
    core/lib/Drupal/Core/Routing/PathChangedHelper.php
    core/modules/block_content/src/Routing/RouteSubscriber.php
    core/modules/file/tests/modules/file_test_views/config/optional/node.type.file_test.yml
    core/modules/file/tests/modules/file_test_views/config/optional/views.view.test_file_to_node.yml
    core/modules/file/tests/modules/file_test_views/config/optional/views.view.test_file_to_user.yml
    core/modules/file/tests/modules/file_test_views/config/optional/views.view.test_file_user_file_data.yml
    core/modules/file/tests/modules/file_test_views/config/optional/views.view.test_node_to_file.yml
    core/modules/file/tests/modules/file_test_views/config/optional/views.view.test_user_to_file.yml
    core/modules/file/tests/src/Kernel/Views/RelationshipNodeFileDataTest.php
    core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
    core/modules/system/tests/modules/path_changed_helper_test/path_changed_helper_test.info.yml
    core/modules/system/tests/modules/path_changed_helper_test/path_changed_helper_test.routing.yml
    core/modules/system/tests/modules/path_changed_helper_test/src/Controller/TestController.php
    core/modules/views/tests/src/FunctionalJavascript/RedirectAjaxTest.php
    core/tests/Drupal/KernelTests/Core/Routing/PathChangedHelperTest.php
    core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php
    core/themes/claro/css/components/dropbutton-noscript.css
    core/themes/claro/css/components/dropbutton-noscript.pcss.css
Please move or remove them before you merge.
Aborting
git pull  0.11s user 0.24s system 16% cpu 2.032 total

I have edited root composer.json but other than that, I haven't touched any files.

EDIT: Output of git status:

➜  dev-drupal git:(11.x) ✗ gst
On branch 11.x
Your branch is behind 'origin/11.x' by 47 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   sites/default/default.settings.php

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    .DS_Store
    .idea/
    .lando.yml
    core/assets/vendor/ckeditor5/horizontal-line/translations/uz.js
    core/assets/vendor/ckeditor5/special-characters/translations/hr.js
    core/assets/vendor/ckeditor5/table/translations/sl.js
    core/lib/Drupal/Core/Routing/PathChangedHelper.php
    core/modules/block_content/src/Routing/
    core/modules/file/tests/modules/file_test_views/config/
    core/modules/file/tests/src/Kernel/Views/RelationshipNodeFileDataTest.php
    core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
    core/modules/system/tests/modules/path_changed_helper_test/
    core/modules/views/tests/src/FunctionalJavascript/RedirectAjaxTest.php
    core/tests/Drupal/KernelTests/Core/Routing/PathChangedHelperTest.php
    core/tests/Drupal/Tests/Core/Routing/PathChangedHelperTest.php
    core/themes/claro/css/components/dropbutton-noscript.css
    core/themes/claro/css/components/dropbutton-noscript.pcss.css
    modules/.DS_Store
    modules/contrib/
    modules/custom/
    sites/default/files/
    sites/default/settings.php
    vendor/

no changes added to commit (use "git add" and/or "git commit -a")
id flag
This sounds unusual. More information is needed.
Kartagis avatar
lu flag
Question edited.
id flag
What does `git status` say before pulling? Git seems to be accurately reporting local changes.
unusedspoon avatar
aq flag
That's the Drupal 11 branch you've got there isn't it, is that what you're expecting?
Kartagis avatar
lu flag
@unusedspoon yes it is.
Kartagis avatar
lu flag
@cilefen the thing is, I have only edited root composer.json.
id flag
Asking again: What does `git status` say before pulling? What actual Git command are you typing that then causes this?
Kartagis avatar
lu flag
Adding the output to the question because it's too long to add here. I'm typing only `git pull`.
id flag
What file system is the disk using?
Jaypan avatar
de flag
Note: The following is destructive, but should work. Use with care: `git reset --hard HEAD; git clean . -f`, then you can run `git pull` after. The two commands will reset your repo to exactly the same as the branch in the repo, by reverting any changes that have been made, and removing any files that aren't tracked by Git.
Kartagis avatar
lu flag
@cilefen it's using apfs.
Kartagis avatar
lu flag
@Jaypan this worked, but will I have to do it every time? What is wrong here? I never had to do this before. Also, please make your comment an answer.
Jaypan avatar
de flag
I don't know how this would have come about, but it shouldn't happen every time I don't think.
Score:0
de flag

The following is destructive, but should work. Use with care: git reset --hard HEAD; git clean . -f, then you can run git pull after. The two commands will reset your repo to exactly the same as the branch in the repo, by reverting any changes that have been made, and removing any files that aren't tracked by Git.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.