← 返回命令列表

Linux command

git-cp 命令

文件

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

常用示例

Copy a file keeping its history

git cp [source_file] [destination_file]

Copy a file to a different directory keeping its history

git cp [path/to/source] [path/to/destination]

说明

git cp is a command from git-extras that copies a file while preserving its Git history. This allows merge conflict handling on the copied file. Unlike a simple filesystem copy followed by git add (which creates a new file with no history), git cp leverages Git's ability to detect file copies through content similarity. When viewing the history of the copied file with git log --follow --find-copies, Git can trace back to the original file's commits. This is particularly useful when creating new files based on templates or when splitting functionality from one file into multiple files while maintaining attribution and history.

FAQ

What is the git-cp command used for?

git cp is a command from git-extras that copies a file while preserving its Git history. This allows merge conflict handling on the copied file. Unlike a simple filesystem copy followed by git add (which creates a new file with no history), git cp leverages Git's ability to detect file copies through content similarity. When viewing the history of the copied file with git log --follow --find-copies, Git can trace back to the original file's commits. This is particularly useful when creating new files based on templates or when splitting functionality from one file into multiple files while maintaining attribution and history.

How do I run a basic git-cp example?

Run `git cp [source_file] [destination_file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more git-cp examples?

This page includes 2 examples for git-cp, plus related commands for nearby Linux tasks.