# git-secure **Repository Path**: xiaofeixia1988/git-secure ## Basic Information - **Project Name**: git-secure - **Description**: git-secure 主要的功能时在用户提交时将用户的代码或者文件使用 AES 加密,然后发布到代码托管平台 - **Primary Language**: PowerShell - **License**: MIT - **Default Branch**: local - **Homepage**: https://www.oschina.net/p/git-secure - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 17 - **Created**: 2020-04-11 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Git Secure Git 安全存储库工具 ## Command |cmd|info| |---|---| |add|Add file contents to the index| |clone|Clone a encrypted repository into a new directory| |config|config your secure repository| |commit|create a commit| |diff|show commit changes between commit worktree,etc| |init|initialize a secure repository| |help|print help information| |key|create a aes key| |pull|Fetch from and integrate with another repository or a local branch| |push|Update remote refs along with associated objects| |remote|set remote for secure repositroy| |status|Show the working tree status| ## 系统依赖 此项目基于 PowerShell 编写,因此,你需要安装 PowerShell 6.0,PowerShell 目前支持 Windows,Linux 和 macOS 你可以去 Github PowerShell 项目的 Release 页面下载 PowerShell:[PowerShell release](https://github.com/PowerShell/PowerShell/releases) 在 Windows 系统上,默认的 Powershell 需要 5.0,也就是说 Windows 7,8.1 需要升级 Powershell 5.0 (Windows 10 默认为 5.0) [Windows Management Framework 5.0](https://www.microsoft.com/en-us/download/details.aspx?id=50395) ## 使用 用户需要在码云上创建一个空仓库。 初始化一个空仓库 ``` git-secure init repo ``` 创建 AES 密钥: ``` git-secure key ``` 添加文件到暂存区: ``` git-secure add ``` 创建 commit: ``` git-secure commit -m "create a new commit" ``` 推送代码: ``` git-secure push ``` 拉取代码(暂时不支持 fetch): ``` git-secure pull ``` 配置: ``` git-secure config aes.key xxxxx ``` ## 功能 git-secure 使用 AES 256 对每一个常规文件加密,这里的常规文件是不包括 commit,及 `.gitignore`,`.gitattributes`,`.gitmodules` 这些文件。 ## 贡献 我们欢迎用户提交 PR,请注意,我们要求代码使用 PowerShell 格式化工具格式化,建议使用 Visual Studio Code (PowerShell 扩展) 修改代码。 ## 备忘 sid 加密目录最新提交的id wid 工作目录最新提交的id commit.ps1流程 工作目录执行commit先将修改提交 获取pointer.json信息 将变更文件复制到隐藏目录 获取工作目录最新一次commit的id 根据id读取日志信息 暂存当前工作目录 设置工作目录为隐藏目录 隐藏目录执行add 和 commit操作 将工作目录和隐藏目录最新的id保存到pointer.json中 clone.ps1流程 过滤部分参数 $dir = url处理 Split-Path -Leaf https://gitee.com/ssunny/git-secure-test.git -> git-secure-test.git -> git-secure-test $Path = "$PWD/$dir" $Parent = $PWD 判断目标目录是否存在 执行git clone 命令 将clone下来的项目重命名为securedirtmp 新建项目目录并创建.git文件夹 将securedirtmp移动并重命名到/.git/secure 保存当前目录 将目录切换到"$Path/.git/secure" 执行 git ls-tree -r HEAD 遍历所有文件并复制到工作目录 回到前面保存的“当前目录” 执行&git init $Path本地git初始化 进入$Path目录 执行&git add -A 执行&git commit -m "$message" 保存工作目录和隐藏目录的最新id到 $Path/.git/pointer.json pull.ps1流程 设置工作目录workdir(E:\Project\PowerShell\git-secure-test) git目录gitdir(E:\Project\PowerShell\git-secure-test\.git) 回到工作目录的上一级目录 进入"$gitdir/secure" 读取gitdir下的pointer.json文件 (隐藏目录下)执行git pull命令 若pointer.json不存在,将隐藏目录下所有项目文件复制到工作目录 若pointer.json存在,则将隐藏目录最新一次commit的id取出获取到当前pull后和上一次commit之前差异的文件列表并复制到工作目录 切换到工作目录取隐藏目录最近一次提交的注释commit所有变动文件 保存工作目录和隐藏目录最新的commit id到pointer.json