git - "git checkout -"是做什么的?

标签 git git-bash git-checkout

我看到了一种奇怪的 git checkout 命令。

git checkout -

- 在这里做什么?

最佳答案

这与执行cd - 是一样的。所以你回到最后一个分支。如果您从 master 开始,这三个序列的作用相同:

# Way 1
git checkout mybranch
git checkout master

# Way 2 (same result)
git checkout mybranch
git checkout -

# Way 3 (same result)
git checkout mybranch
git checkout @{-1}

作为chepner提到,您可以使用 @{-N}

返回到先前 checkout 的第 n 个分支

关于git - "git checkout -"是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47204309/

相关文章:

git - 使用 "git checkout"时修改后的文件会发生什么?

git - 从 svn 转换为 git 后如何从分支名称中删除远程源

node.js - 仅在发生更改时才构建项目

git - 撤消 git checkout --orphan

bash - 如何在 bash 中测试一个字符串是否以另一个字符串开头?

ruby-on-rails - Gitbash Windows 10 中的 Heroku 错误

git bash 自动完成在 Windows 7 x64 上很慢

git reset --soft - 它返回到 git checkout 点还是最后一个 git merge 点?

Git check out 文件 - 文件名中的大小写

compilation - 数组 '__curl_rule_01__' 的大小为负