user1122445
user1122445

Reputation: 141

git: how to push without checking out?

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.

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.

Upvotes: 4

Views: 4194

Answers (3)

Adam Dymitruk
Adam Dymitruk

Reputation: 129526

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.

Upvotes: 0

Kjuly
Kjuly

Reputation: 35131

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..).

Upvotes: 2

Robert Rouhani
Robert Rouhani

Reputation: 14678

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.

Upvotes: 0

Related Questions