← 返回命令列表

Linux command

git-force-clone 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Force clone

git force-clone [url] [directory]

Force clone at a specific branch

git force-clone -b [branch] [url] [directory]

Force clone and reset to the remote head

git force-clone [https://github.com/owner/repo.git] [existing-dir]

说明

git force-clone from the git-extras suite guarantees the target directory ends up as a fresh, clean clone of the given URL. It is the "just give me what's on the remote" hammer for deployment scripts: - If the directory does not exist, it clones normally. - If the directory is already a clone of the same URL, it fetches and hard-resets the working tree to match the remote, discarding any local changes. - If the directory exists but is a different repository (or contains unrelated files), it removes the directory and re-clones.

参数

-b _BRANCH_
Check out _BRANCH_ after cloning.
--help
Show help.

FAQ

What is the git-force-clone command used for?

git force-clone from the git-extras suite guarantees the target directory ends up as a fresh, clean clone of the given URL. It is the "just give me what's on the remote" hammer for deployment scripts: - If the directory does not exist, it clones normally. - If the directory is already a clone of the same URL, it fetches and hard-resets the working tree to match the remote, discarding any local changes. - If the directory exists but is a different repository (or contains unrelated files), it removes the directory and re-clones.

How do I run a basic git-force-clone example?

Run `git force-clone [url] [directory]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -b _BRANCH_ do in git-force-clone?

Check out _BRANCH_ after cloning.