1

Problem:

we have 2 repo's. working on repo A and once each X days (or when repo A is stable) we update repo B to be exactly like repo A (excluding some files from repo A)

Example:

2 repo's (each with its own git)

repoA
+-pom.xml
+-src

repoB
+-pom.xml
+-src

want to run a script that will once every X days take all commits from repoA that didnt affect pom.xml and apply them as 1 commit in repo B

eventually repoB src folder should be exactly the same as repoA src folder

thinking of taking the easy path and just using a bash script

mkdir /tmp/repoA
cp /repoA /tmp/repoA
rm /tmp/repoA/pom.xml
mv /tmp/repoA repoB
git commit -m "updated repo B"
git push

some1 has a better idea doing this using git and not just plain old mv ??

Nimrod007
  • 9,825
  • 8
  • 48
  • 71

1 Answers1

1

You could simply specify the working tree (of repoA) when updating repoB:

cd /path/to/repoB
git --work-tree=/path/to/repo/A add -A .
git checkout pom.xml
git commit -m "update repo B"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • nice! after doing this I want to continue working on repoB , how can i "unset" the --work-tree ? – Nimrod007 Sep 06 '15 at 11:29
  • 1
    @Nimrod007 the work-tree is only set for the `git add` command. – VonC Sep 06 '15 at 11:30
  • dont u need to do: git reset HEAD pom.xml ?? – Nimrod007 Sep 06 '15 at 18:19
  • @Nimrod007 no reset: checkout, in order to restore the content of pom.xml as in master branch. You want to update the working tree, not just the index: see http://stackoverflow.com/a/3639387/6309 – VonC Sep 06 '15 at 18:20