红穆笔记

git cp

複製 Git 倉庫中的文件並保留歷史記錄。 屬於 `git-extras` 的一部分

100% 瀏覽器本地處理 0 數據上傳

常用示例

在當前 Git 倉庫下複製文件,保留在同一目錄

git cp {{原文件名}} {{新文件}}

複製文件到其他目錄

git cp {{路徑/到/源文件}} {{路徑/到/新文件}}

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Copy an existing file to a new location, preserving history. Part of `git-extras`. More information

Copy an existing file in a Git repo, staying in the same directory

git cp {{file}} {{new_file}}

Copy an existing file in a Git repo and place it elsewhere

git cp {{path/to/file}} {{path/to/new_file}}

命令信息

命令名git cp
用途複製 Git 倉庫中的文件並保留歷史記錄。 屬於 `git-extras` 的一部分
適用平臺通用
示例數量2 條
官方文檔https://github.com/tj/git-extras/blob/main/Commands.md#git-cp
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

git cp 命令是做什麼的?

複製 Git 倉庫中的文件並保留歷史記錄。 屬於 `git-extras` 的一部分

git cp 怎麼用?

頁面按場景列出了2 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

git cp 最常用的操作是什麼?

在當前 Git 倉庫下複製文件,保留在同一目錄:git cp {{原文件名}} {{新文件}}

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。