简体   繁体   English

git chaining:git push 来自本地更新的遥控器的 remotes ref。 为什么以及如何可能?

[英]git chaining: git push from local updated remote's remotes ref. Why and how was it possible?

I'm facing weird (IMO) issues with my repo and start to question what I assumed.我的回购协议面临着奇怪的 (IMO) 问题,并开始质疑我的假设。 That is chaining of repos.那就是回购链。 Web search "git chaining repos" gave https://serverfault.com/questions/186161/possible-to-chain-git-repos where the answer "yes, of cause".网络搜索“git chaining repos”给出了https://serverfault.com/questions/186161/possible-to-chain-git-repos答案“是的,原因”。

Now I just did git push origin HEAD:refs/remotes/origin/main in local (1st repo), in .git/config of 1st there is URL for origin (2nd repo).现在我只是在本地(第一个回购)中执行了git push origin HEAD:refs/remotes/origin/main ,在第一个的.git/config中有origin (第二个回购)的 URL。

In that 2nd repo in .git/config there is URL of 3rd repo as origin ..git/config的第二个回购中,有第三个回购的 URL 作为origin But after push which outputted several objects in delta, I did not see those by git reflog on 2nd.但是在 delta 中输出了几个对象的push之后,我在 2nd 没有看到git reflog的那些。 Instead I saw in 2nd in refs/remotes/origin/main file hash of last commit pushed from 1st repo.相反,我在refs/remotes/origin/main文件哈希中看到了从第一个 repo 推送的最后一次提交的第二个。

How do you think that happened?你认为这是怎么发生的? Maybe some internal `damage' to repo(s)?也许对回购协议有一些内部“损害”? Other issues that lead me to investigate are in git fetch - "refuse", git pull "forced update, fetch updated current branch head".导致我调查的其他问题在git fetch - “拒绝”,git pull “强制更新,获取更新的当前分支头”。 Local was 2 commits ahead of remote . Local 比 remote 提前 2 次提交 TIA TIA

git version 2.25.1 git 版本 2.25.1

Added:添加:

Yesterday repos seemed fine, I recall I first synced 1st and 2nd, then 2rd and 3nd, today I wanted to sync 1st and 2nd.昨天回购似乎还不错,我记得我先同步了 1st 和 2nd,然后是 2rd 和 3nd,今天我想同步 1st 和 2nd。

The only unusual thing I did I recall today after pull from 2nd to 1st there was a conflict, I did git reset FILE in 1st for file with that conflict and replaced (copied to repo folder) the file from backup outside of git.我今天记得的唯一不寻常的事情是,从第 2 次拉到第 1 次后发生了冲突,我在第 1 次中为具有该冲突的文件执行了git reset FILE ,并从 git 外部的备份中替换(复制到 repo 文件夹)文件。

git did what it was told to, push to origin HEAD:refs/remotes/origin/main , which is remote on remote. git做了它被告知的事情,推送到origin HEAD:refs/remotes/origin/main ,这是远程远程。

When troubleshooting I noticed in .git/config entry for main was different, extra remotes .在进行故障排除时,我注意到.git/config中的main条目是不同的,额外的remotes Apparently it set main to track main on remote's remote (further down the chain).显然,它将 main 设置为跟踪 remote 的 remote 上的 main (在链的更下方)。

Also I recall I saw git-branch --set-upstream-to=main main produces effect of setting main branch to track origin's main and git-branch --set-upstream-to=origin/main main produce config change as described above.我还记得我看到git-branch --set-upstream-to=main main产生设置main分支以跟踪原点的 main 和git-branch --set-upstream-to=origin/main main产生如上所述的config更改的效果. I was because I've made repo with git clone --mirror which sets refs translation in .git/config as fetch = +refs/*:refs/* whereas with regular clone : fetch = +refs/heads/*:refs/remotes/origin/* .我是因为我已经使用git clone --mirror进行了回购,它将.git/config中的 refs 翻译设置为fetch = +refs/*:refs/*而使用常规clonefetch = +refs/heads/*:refs/remotes/origin/*

I think one needs to look attentively to output of the command to know the result.我认为需要仔细查看命令的输出才能知道结果。

To find out the cause of the issue included me running strace , seeing code only reads .git/config in user home, .git/config , .git/HEAD , .git/refs/heads/main and then realizing .git/config entry differs from entries for other repo (extra /remotes ).为了找出问题的原因,我运行了strace ,看到代码只读取用户主目录中的 .git/ .git/config.git/config.git/HEAD.git/refs/heads/main然后实现.git/config条目不同于其他回购的条目(额外的/remotes )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM