gpt4 book ai didi

GIT - checkout 到分支名称以 '<' 符号开头

转载 作者:太空狗 更新时间:2023-10-29 13:59:10 27 4
gpt4 key购买 nike

我创建了一个名为 <title>-changes 的分支通过:

git checkout -b <title>-changes并在那个分支上做了一个提交。后来我 checkout 到another-branch开始研究 another-branch .现在我想 checkout 到以前的分支 ( <title>-changes ) 但我现在不能这样做:

git checkout <title>-changes

我知道这是一个简单的问题,但无法破解。我试过:

git checkout \<title>-changes
git checkout /<title>-changes
git checkout '<title>-changes'

但运气不好。出现如下错误:

$error: pathspec '<title' did not match any file(s) known to git.
$bash: title: No such file or directory
$error: pathspec '<title>-change-pdp ' did not match any file(s) known to git.

最佳答案

你必须同时转义 <>因为 bash 将它们视为特殊符号。

为此,在前面加上反斜杠 \对他们每个人:

git checkout \<title\>-changes

这就是我所做的测试,它奏效了。

mkdir test
cd test/
git init
git branch \<title\>-changes
touch empty
git add empty
git commit -m "Added empty file"
git branch \<title\>-changes
git checkout \<title\>-changes
touch second
git add second
git commit -m "Added second empty file"
git checkout -b another-branch
touch third
git add third
git commit -m "Added third empty file"
git checkout \<title\>-changes

关于GIT - checkout 到分支名称以 '<' 符号开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37724794/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com