ncf
ncf

Reputation: 556

Update all local copies with git

I have two local copies of a repository, say a and b, and both local copies have cloned from a remote origin. How can I automatically pull changes from the master branch on b when a does a commit and push in this branch?

Note: b will only be on the master branch at all times, and should only update when origin/master has been pushed/merged or updated in any way.

Upvotes: 2

Views: 55

Answers (2)

yanghaogn
yanghaogn

Reputation: 853

push local master branch to remote b's master branch

git push b master:master  

fetch and merge remote b's master branch with current local branch

git pull b/master

Upvotes: 0

code_monk
code_monk

Reputation: 10130

Use Hooks.

You would create a pre-push hook on repo a, that triggers the git commands that update b. There would be no need to pull from origin. b could simply pull from a.

And note that you can use local filesystem paths with git operations. as in:

git push /path/to/b origin/master

Upvotes: 2

Related Questions