Git checkout 双破折号的含义 [英] Meaning of Git checkout double dashes

查看:45
本文介绍了Git checkout 双破折号的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个git命令中文件名前的双破折号是什么意思?

What is the meaning of the double dashes before the file name in this git command?

git checkout --ours -- path/to/file.txt
git checkout --theirs -- path/to/file.txt

它们是强制性的吗?是否等价于

Are they mandatory? Is it equivalent to

git checkout --ours path/to/file.txt
git checkout --theirs path/to/file.txt

推荐答案

假设我的 Git 存储库中有一个名为 path/to/file.txt 的文件,我想恢复对它的更改.

Suppose I have a file named path/to/file.txt in my Git repository, and I want to revert changes on it.

git checkout path/to/file.txt

现在假设文件名为 master...

Now suppose that the file is named master...

git checkout master

哎呀!而是改变了分支.-- 将要签出的树与要签出的文件分开.

Whoops! That changed branches instead. The -- separates the tree you want to check out from the files you want to check out.

git checkout -- master

如果某个怪胎在我们的存储库中添加了一个名为 -f 的文件,它也会对我们有所帮助:

It also helps us if some freako added a file named -f to our repository:

git checkout -f      # wrong
git checkout -- -f   # right

这在 git-checkout: Argument Disambiguation 中有记录.

这篇关于Git checkout 双破折号的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆