Reputation: 11
I got a conflicted files that haven't been solved for a while. I tried to use the following command:
git checkout MOODLE_31_STABLE $(grep -rwl "<<<<<<< HEAD")
which tries to to check out each conflicted file and replaced it by MOODLE_31_STABLE copy.
unfortunately , for some files I get this error:
error: pathspec 'theme/boost/config.php' did not match any file(s) known to git.
error: pathspec 'theme/boost/lang/en/theme_boost.php' did not match any file(s) known to git.
error: pathspec 'theme/boost/readme_moodle.txt' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/bootstrap.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/mixins/_forms.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/mixins/_grid-framework.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/mixins/_grid.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/mixins/_text-emphasis.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/utilities/_background.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/utilities/_visibility.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_alert.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_card.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_input-group.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_media.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_navbar.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_print.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_progress.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_reboot.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_tables.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/bootstrap/_variables.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/moodle/course.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/scss/preset-default.scss' did not match any file(s) known to git.
error: pathspec 'theme/boost/settings.php' did not match any file(s) known to git.
error: pathspec 'theme/boost/templates/core/dataformat_selector.mustache' did not match any file(s) known to git.
error: pathspec 'theme/boost/templates/mod_assign/grading_navigation.mustache' did not match any file(s) known to git.
error: pathspec 'theme/boost/thirdpartylibs.xml' did not match any file(s) known to git.
I've checked and the branch has been checked out, so it IS in local. the files do exist in both branches... So I really don't understand why I get the errors.
Upvotes: 1
Views: 59
Reputation: 1323115
As I illustrated here, starting with Git 2.23 (August 2019), you would use the new git restore
command.
git restore -s anotherBranch --staged --worktree -- aFile
# shorter:
git restore -s anotherBranch -WS -- aFile
Then adding and committing the file should be enough to mark it as "resolved".
Upvotes: 0
Reputation: 520878
If you have a file in conflict and you are sure that you want to replace it with a version from another branch, then you can use this syntax:
git checkout other_branch -- path/to/some/file.ext
^^^ name of branch ^^^ path of file
After this, you would still have to mark the file as resolved and complete the merge. You can repeat the above for however many files you need. If you are doing this for a massive number of files, then I would say your Git workflow might have a smell, and you might want to reconsider changing it.
Upvotes: 1