简体   繁体   English

Git-仅将更改的文件拉到单独的文件夹中

[英]Git - pull only changed files into a separate folder

Situation: I would like to do a git pull, but then the new files have to be moved to an offline machine. 情况:我想进行git pull,但是新文件必须移至离线计算机。

The question is: Is it possible to download into a new folder only the files that are changed since the current commit? 问题是:是否可以仅将自当前提交以来已更改的文件下载到新文件夹中? If it would keep the folder structure, that also would be awesome! 如果它能保留文件夹结构,那也太棒了!

You could write a shell script to do it. 您可以编写一个shell脚本来做到这一点。

Assuming you are on the master branch and your changes live on the origin remote: 假设您位于master分支上,并且所做的更改位于origin远程服务器上:

  1. Get the latest changes with git fetch origin 使用git fetch origin获取最新更改
  2. Change your working directory to the latest changes: git checkout origin/master 将工作目录更改为最新更改: git checkout origin/master
  3. Determine which files have changed with: git diff --name-status master..origin/master 使用以下命令确定哪些文件已更改: git diff --name-status master..origin/master
  4. Copy those files to a new folder 将这些文件复制到新文件夹
  5. Go back to your original branch: git checkout master 返回原始分支: git checkout master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM