Git报错error:pathspec‘XXX‘didnotmatchanyfile(s)knowntogit问题及解决过程

作者:

文章目录
  • ① 在本地分支切换到同事新创建的分支: git checkout xxx ② 报错: error: pathspec 'XXX' did not match any file(s) known to git
  • ① 查看本地的所有的分支中是否有同事新创建的分支: git branch -a ② 如果没看到,那么执行以下操作,这步是获取所有分支: git fetch ③ 执行完会看到这样提示: remote: Enumerating objects: 4, done.remote: Counting objects: 100% (4/4), done.Unpacking objects: 100% (4/4), 1.06 KiB | 90.00 KiB/s, done.From codeup.aliyun.com:5eeb0689892c58bb7c394ab5/pxb/pxb-fronted * [new branch]      XXX -> origin/XXX ④ 切换到远程同事分支: git checkout origin/XXX 提示: Note: switching to 'origin/XXX'. You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -c with the switch command. Example:   git switch -c <new-branch-name> Or undo this operation with:   git switch – Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at dc877cd XXX ⑤ 现在可以看到自己的分支是一串数字字母,这时新建并切换到同事的分支: git checkout -b XXX ⑥ 现在需要跟远程的同事分支进行关联: git branch -u origin/XXX XXX ⑦ 这时我们执行git pull来看看什么反馈: git pull Already up-to-date. ⑧ 此时,可以如果修改了代码后,需要进行的操作就是: 查看修改状态:git status -s 添加到本地暂存区:git add ./ 添加到本地仓库:git commit -m “[ADD]新增了某功能” 添加到远程仓库,远程仓库中会多一个分支xxx:git push origin xxx
  • 以上为个人经验,希望能给大家一个参考,也希望大家多多支持风君子博客。 您可能感兴趣的文章: npm run serve运行vue项目时报错:Error: error:0308010C:digital envelope routines::unsupported的解决方法 git clone报错SSL connect error解决 python解决报错ImportError: Bad git executable.问题 vue-cli-service serve报错error:0308010C:digital envelope routines::unsupported Vue报错error:0308010C:digital envelope routines::unsupported的解决方法
  • 目录
    • 问题复现
    • 解决方法
    • 总结

    ① 在本地分支切换到同事新创建的分支:

    git checkout xxx

    ② 报错:

    error: pathspec 'XXX' did not match any file(s) known to git

    ① 查看本地的所有的分支中是否有同事新创建的分支:

    git branch -a

    ② 如果没看到,那么执行以下操作,这步是获取所有分支:

    git fetch

    ③ 执行完会看到这样提示:

    remote: Enumerating objects: 4, done.
    remote: Counting objects: 100% (4/4), done.
    Unpacking objects: 100% (4/4), 1.06 KiB | 90.00 KiB/s, done.
    From codeup.aliyun.com:5eeb0689892c58bb7c394ab5/pxb/pxb-fronted
     * [new branch]      XXX -> origin/XXX

    ④ 切换到远程同事分支:

    git checkout origin/XXX

    提示:

    Note: switching to 'origin/XXX'.

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by switching back to a branch.

    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -c with the switch command. Example:

      git switch -c <new-branch-name>

    Or undo this operation with:

      git switch –

    Turn off this advice by setting config variable advice.detachedHead to false

    HEAD is now at dc877cd XXX

    ⑤ 现在可以看到自己的分支是一串数字字母,这时新建并切换到同事的分支:

    git checkout -b XXX

    ⑥ 现在需要跟远程的同事分支进行关联:

    git branch -u origin/XXX XXX

    ⑦ 这时我们执行git pull来看看什么反馈:

    git pull
    Already up-to-date.

    ⑧ 此时,可以如果修改了代码后,需要进行的操作就是:

    查看修改状态:git status -s
    添加到本地暂存区:git add ./
    添加到本地仓库:git commit -m "[ADD]新增了某功能"
    添加到远程仓库,远程仓库中会多一个分支xxx:git push origin xxx

    以上为个人经验,希望能给大家一个参考,也希望大家多多支持风君子博客。

    您可能感兴趣的文章:

    • npm run serve运行vue项目时报错:Error: error:0308010C:digital envelope routines::unsupported的解决方法
    • git clone报错SSL connect error解决
    • python解决报错ImportError: Bad git executable.问题
    • vue-cli-service serve报错error:0308010C:digital envelope routines::unsupported
    • Vue报错error:0308010C:digital envelope routines::unsupported的解决方法

    站内搜索