git:如何在不签出的情况下进行推送? [英] git: how to push without checking out?

查看:90
本文介绍了git:如何在不签出的情况下进行推送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台计算机A和B,并使用git sync一些文件,例如init.el. A的回购存放在未附带通知的主机上. B的仓库是本地的.

  • A中的init.el被修改并推送.
  • B中的
  • init.el也被修改.

问题是:如何将A的更改合并到B中,并将最终的init.el推入非混淆(A),而不会在B中扩展A的所有文件

还是有更好的解决方案?

谢谢.

解决方案

因此,如果您不想提取在A处修改过的文件,则可以这样做:

B处,创建一个新分支并将其推送到远程服务(如您所说,解除捆绑):

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

A,提取在B创建的分支的更新,管理合并&冲突:

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拉(妈妈,这有点麻烦.).

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.

解决方案

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

这篇关于git:如何在不签出的情况下进行推送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆