2

I have two remote repositories. The first one (Framework) get's pulled into the second one (MySite). I make some changes to MySite, like CSS for example, and push it all to the MySite repo.

Now, if I (or another dev) change a PHP file, User.php for example (which is stored on the Framework repo), on the MySite repo and pull the Framework repo into MySite that User.php file needs to be overwritten using the file on the Framework repo.

Here is my local git config:

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "MySite"] url = [email protected]:mysite fetch = +refs/heads/*:refs/remotes/MySite/* gtPrivateKeyPath = /Users/MY_MAC_USER/.ssh/my_key sslVerify = true [branch "master"] remote = MySite merge = refs/heads/master [remote "Framework"] url = username@ domain.com:framework fetch = +refs/heads/*:refs/remotes/Framework/* gtPrivateKeyPath = /Users/MY_MAC_USER/.ssh/my_key sslVerify = true 

Folder structure for Framework repo:

application/ modules/ User/ User.php public/ images/ themes/ default/ css/ settings.php.sample tmp/ 

Folder structure for MySite repo

application/ modules/ User/ User.php public/ images/ themes/ default/ css/ MySite_Theme/ css/ settings.php settings.php.sample tmp/ 

When I pull Framework, it doesn't do anything (unless the files were changed on Framework.

Is it because MySite is the first repo listed?

How can I get Framework to overwrite any files that are in the Framework repo when it get's pulled into MySite?

0

1 Answer 1

1

In the scenario that you have described, the Framework repo is usually referred to as the upstream repo. For you to update your MySite repo getting the changes from the Framework repo and overwriting any changes in the conflicting files, these commands should do that:

$ git checkout master # make sure you're on your master branch in MySite $ git fetch Framework $ git merge -s recursive -X theirs Framework/master 

That will pull in the changes from the Framework repo and any file that is conflicted during the merge will be overwritten with the file from Framework.

Sign up to request clarification or add additional context in comments.

6 Comments

That's what I thought it should be but that is not doing what I thought it would do. I made changes on the MySite repo to files that are in the Framework repo. Then when I pull Framework I want it to overwrite the changes I made to that file. But I can't use reset because there are files on MySite that are not in Framework.
I've updated my answer to better address your situation.
That did nothing. There's no conflicts or anything.
Then I don't think I understand the problem. Can you show what your folder structure is like and which files you're expecting to be changed?
Added the folder structure for both repos. When creating a new website, I pull Framework into the new website repo (MySite) then I create some files needed for the site like settings.php, and a theme, then I push it to the remote MySite repo. User.php should only be changed on the Framework repo, then pulled into MySite. But if for some reason another dev does edit User.php on the MySite repo, I want it to be overwritten by the one on Framework when they pull Framework into MySite later on to get updates.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.