Git - copy all files from one branch to an arbitrary folder in the current branch, non-stationary

Suppose I have the following two branches and the local branch is "mybranch"

master master\file.txt master\directory\file2.txt ... mybranch mybranch\otherfile.txt 

I would like to create a new directory, name it 'test'. I would like to add ALL the contents of the wizard to mybranch\test . I do not want these files and directories to be delivered, just copied.

I tried git checkout mybranch -- with various combinations of wildcards, slashes, periods, and I just can't get it to work.

So in this example, my end result will be

 mybranch mybranch\otherfile.txt mybranch\test\file.txt mybranch\test\directory\file2.txt 

Can this be done without switching branches?

+4
source share
1 answer

As suggested in response to this question , you can use git archive to extract the contents of the commit, and then extract the archive to the desired location:

 git archive master | tar -x -C test 
+5
source

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


All Articles