How to export all modified files between two git fixed in SourceTree?

In TortoiseGit and TortoiseSVN, you can export all modified files between two versions, including the directory structure, to an external folder.

Is there a way to do this in Atlassian SourceTree (for Windows)?

+8
source share
4 answers

Try the following:

git archive --output=test_zip.zip HEAD $(git diff --diff-filter=ACMRTUXB --name-only hash1 hash2) 

Just replace hash 1 and hash 2 in the example with the desired commit hash and name the zip file in which you want your changes to be archived.

It works for me

+8
source

Here is a solution using 7zip with a custom action ( Tools > Options > Custom Actions > Add ):

 Menu caption: > dist.zip [ ] Open in a separate window [ ] Show Full Output [X] Run command silently Script to run: X:\Your\path\to\7-Zip\7z.exe Parameters: a $REPO\dist.zip $FILE (Restart SourceTree after creation for the changes to take effect!) 

This action works from the context menu for Unstaged Files and modified files in the commits from the log / history (even if several files / several commits are selected) and adds these files to "dist.zip" in the root of the repo. Just note that the file will not be deleted until the files are added, so if you want to start from scratch, remember to delete the zip file first.

Thanks to this, it has become much easier to update working systems using only modified files in projects that do not use the build system. I wonder how I managed to live and work so long without him? :-)

+1
source

Within sourcetree:

  • Choose the first commit, starting at
  • Hold shift
  • Click on the last commit you want to export
  • Right-click and select Create Patch
  • Set the file name to save and the patch is ready

enter image description here


Using CLI:

Open terminal (icon in sourcetree icon bar)

Then enter:

 git diff <sha-1>..HEAD > my_all_commits.diff 

It will create a diff file with all the changes in the given range.


How to create a single fix patch

git format-patch SHA-1..SHA-1 .
This commit will create a fix set for each commit with all changes to the commit. Then you can use them all or just to select the ones you want to apply in the second repo.

Good luck.

0
source

I made this code for custom actions on windwos.bat

single commit (google search) [question]: Create an archive of modified files in GIT via a batch file

 setlocal enabledelayedexpansion set output= for /f %%G in ('git diff-tree --no-commit-id --name-only -r %1^^') do ( set output=!output! "%%G" ) git archive -o update.zip %1 %output% endlocal 

Between commits (top variation)

 setlocal enabledelayedexpansion set output= for /f %%G in ('git diff-tree --no-commit-id --name-only -r %2^^ %1') do ( set output=!output! "%%G" ) git archive -o update.zip %1 %output% endlocal 

You must set the $ SHA parameter

-1
source

Source: https://habr.com/ru/post/988009/


All Articles