Git - 将更改从克隆拉回主服务器 [英] Git - pulling changes from clone back onto the master

查看:19
本文介绍了Git - 将更改从克隆拉回主服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个 Git master 并在克隆上做了很多更改.我已经在克隆上提交了这些更改,现在希望 master 成为克隆上内容的副本.

I cloned a Git master and made a lot of changes on the clone. I have since committed these changes on the clone and now want the master to be a carbon copy of what is on the clone.

我已经尝试在克隆上使用 Git push 将更改推送到主服务器 - 但我没有做任何更新主服务器的操作.

I've tried Git push on the clone to push the changes to the master - but nothing I do updates the master.

我怎样才能让 master 成为克隆上内容的精确副本?更新克隆和使主与克隆同步的命令工作流程是什么?

How can I make the master an exact copy of what is on the clone? What is the command workflow of updating the clone and having the master sync with the clone?

推荐答案

git 仓库有两种,裸和非裸.非裸存储库是任何具有工作副本"的存储库,即当前检出的存储库的某些部分.

There are 2 kinds of git repository, bare and non-bare. A non bare repository is any repository which has a 'working copy' i.e. some part of the repository currently checked out.

可以推送到非裸存储库,但即使签出的分支与您推送的分支相同,它也不会更新签出的工作副本.这是因为检出的副本可能有未提交的更改,并且 git 永远不会在没有您明确询问的情况下销毁更改(通常此类命令有一个 --hard 参数)

You can push into a non-bare repository, but it won't update the checked out working copy even if the checked out branch is the same as the branch you pushed. This is because the checked out copy might have changes that aren't committed, and git won't ever destroy changes without you explicitly asking (usually such commands have a --hard argument)

阅读 为什么我在git push"之后看不到远程仓库的变化?我将如何使用git push"进行同步在防火墙主机之外? 获取问题的完整描述和潜在的解决方案.警告的话,如果您已推送到远程存储库,则必须丢弃该远程存储库中任何未提交的更改.

Read Why won't I see changes in the remote repo after "git push"? and How would I use "git push" to sync out of a firewalled host? for a full description of the problem and a potential solution. Word of warning, if you've pushed into a remote repo, any non-committed changes in that remote-repo will have to be discarded.

通常听起来您想要的方法并没有真正被 gitter 采用,因为它并不真正符合分布式存储库的心态.您有责任确保您的存储库副本是最新的.

Generally it sounds like the approach you want isn't really adopted by gitters, because it doesn't really match the distributed repository mentality. It's your own responsibility to make sure your copy of the repo is up to date.

这篇关于Git - 将更改从克隆拉回主服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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