Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace the contents of one directory in GIT

Tags:

git

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

Imagine that I want to get rid of contents of Dir2 and replace them with Dir2 in the master branch, while keeping the content of Dir1.

I don't expect this to be that simple, but ideally :

cd Dir2
git [magic that replaces current dir with the contents of master branch]
like image 588
kms333 Avatar asked Sep 13 '12 10:09

kms333


1 Answers

remove Dir2 from branchA and
fetch it from master branch:

$ git checkout branchA
$ git rm -r Dir2
$ git checkout master -- Dir2
$ git commit -m "replaced Dir with Dir2 from master"
like image 103
c00kiemon5ter Avatar answered Nov 13 '22 06:11

c00kiemon5ter