将来自不同分支的文件签出到当前分支中的不同路径

时间:2015-11-02 22:50:35

标签: git path copy git-branch git-checkout

所以我知道我们可以通过以下方式将其他分支机构的文件签出到我们当前的工作分支中:

# artificial data frame
data <- data.frame(x=runif(16), y=runif(16), panel = rep(c("alpha", "beta", "gamma","delta"), 4))
p <- ggplot(data, aes(x,y)) + geom_point() + facet_wrap(~panel)

# no changes, wrap panel headers stay the same
facet_wrap_labeller(p) 

# replace each panel title statically
facet_wrap_labeller(p, labels = expression(alpha^1, beta^1, gamma^1, delta^1)) 

# only alpha and delta are replaced
facet_wrap_labeller(p, labels = expression(alpha = alpha^2, delta = delta^2)) 

# parse original labels
facet_wrap_labeller(p, labeller = label_parsed) 

# use original labels but modifying them via bquote
facet_wrap_labeller(p, labeller = label_bquote(.(x)^3)) 

# custom function (e.g. for latex to expression conversion)
library(latex2exp)
facet_wrap_labeller(p, labeller = function(var, val) { 
  lapply(paste0("$\\sum\\", val, "$"), latex2exp)
}) 

我希望这样的事情是可能的:

git checkout [someOtherBranch] [path/to/file]

这可能吗?

1 个答案:

答案 0 :(得分:3)

您可以捕获文件的内容,然后使用标准的shell重定向将其放在任何您想要的位置。

git show [someOtherBranch]:path/to/file > newpath/to/file