[英]Switching git branch with ruby-git does not switch the files?
I am cloning a Github repo that has multiple branches, like for example:我正在克隆一个具有多个分支的 Github 存储库,例如:
root_dir = Dir.mktmpdir(nil, Rails.root.join("repos").to_s)
root_folder = "ruby_git"
Git.clone("https://github.com/ruby-git/ruby-git.git", root_folder, :path => root_dir)
I then try to switch the branch to "test"
:然后我尝试将分支切换到
"test"
:
g = Git.open(full_dir)
if g.current_branch != "test"
puts g.branch("test").checkout # => "Switched to branch 'test'"
end
The branch switch is confirmed.确认分支开关。 I even test myself if the branch is correct:
我什至测试自己分支是否正确:
puts g.current_branch # => "test"
But when I finally check the files like this:但是当我最终检查这样的文件时:
puts Dir["#{full_dir}/tests/*"] # => Wrong files that belongs to the default branch...
I see that the folder still contains the files of the default branch, not the branch that I switched to.我看到该文件夹仍然包含默认分支的文件,而不是我切换到的分支。
What am I doing wrong, and how can I fix it?我做错了什么,我该如何解决?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.