我有两台电脑A和B,用git同步了一些文件,比如init.el。
A 的 repo 托管在 unfuddle 上。 B的repos在本地。
- 修改并推送A中的init.el。
- B中的init.el也被修改。
问题是:如何将 A 的更改 merge 到 B 的更改并将最终的 init.el push unfuddle (A),无需扩展 A 在 B 中的所有文件。
或者有更好的解决方案?
谢谢。
最佳答案
所以,如果你不想 pull 在A
处修改的文件,你可以这样做:
在 B
处,创建一个新分支并将其推送到远程服务(unfuddle,如您所说):
cd path/to/init.el
git branch featureModifiedInB
git checkout featureModifiedInB
git push origin featureModifiedInB
在A
, pull 在B
创建的分支的更新,管理 merge 和冲突:
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
它确保使用B
的人看不到使用A
的人编辑的文件。但这会导致一个问题:pB 无法获得有关她/他创建的代码的反馈。但是pA也可以修改featureModifiedInB
分支,让pB来 pull (mum..有点麻烦..)。
关于git:如何在不 checkout 的情况下推送?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8676903/