Replace the contents of one directory in GIT

Imagine that I have a repository with the Dir1 and Dir2 directories, and I in branchA.

Imagine that I want to get rid of the contents of Dir2 and replace them with Dir2 in the main branch, preserving the contents of Dir1.

I do not expect this to be so simple, but ideally:

cd Dir2 git [magic that replaces current dir with the contents of master branch] 
+4
source share
1 answer

remove Dir2 from branchA and
extract it from the master branch:

 $ git checkout branchA $ git rm -r Dir2 $ git checkout master -- Dir2 $ git commit -m "replaced Dir with Dir2 from master" 
+11
source

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


All Articles