4

I have two computers A and B, and use git sync some files, init.el for example. A's repos is hosted on unfuddle. B's repos is locally.

  • init.el in A is modified and pushed.
  • init.el in B is modified, too.

The question is: how to merge A's changes into B's and push the final init.el into unfuddle (A), without expanding A's all file in B.

Or there is a better solution?

Thanks.

user1122445
  • 141
  • 1
  • 5

3 Answers3

2

So, if you do not want to pull the files that modified at A, you can do like this:

At B, create a new branch and push it to remote service(unfuddle, as you said):

cd path/to/init.el
git branch featureModifiedInB
git checkout featureModifiedInB
git push origin featureModifiedInB

At A, pull the update of branch that created at B, manage the merge & conflict:

cd path/to/init.el
git pull origin featureModifiedInB  // Or you can do fetch and manually do merging.
git checkout master
git merge featureModifiedInB

// After solve the conflict if it exists.
git push origin master

It makes sure that person using B can not see the files that edited by person who uses A. But this'll cause a problem: pB cannot get feedback about the code s/he created. But pA can also modify the featureModifiedInB branch and let it pulled by pB(mum..it's a little bit troublesome..).

Kjuly
  • 34,476
  • 22
  • 104
  • 118
0

There are a few options:

  • If you don't want to keep A's changes, git push -f origin master. Note that forcing a push will cause some issues for anyone who branched from you and wants to merge.
  • Soft reset to the last common commit between A and B, git stash, pull, merge, pop the stash (merge the stash with current code), commit, and push. If anyone branched off from you after that common commit, they won't be able to merge back in very easily, if at all.
Robert Rouhani
  • 14,512
  • 6
  • 44
  • 59
0

If A and B are totally unrelated (as you say "A's files are not be aware of B's files and vice versa") then you don't need to merge them. Just push A and B and don't merge them.

If you want more separation, create another repository to house the work in B. Use unfuddle to allow/disallow access.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141