be yet to用法

邮件里的句子We are yet to finalize all the user stories and Joanna is swamped with XXproduction work.

be yet to的用法:http://www.englishforums.com/English/BeYetToDo/xddbk/post.htm
"Yet" means "still", or "remaining," in this context.

This remains to be done.

This is still to be done.

This is yet to be done.

What is there to do?

What is [there] yet to do?

This is yet to do.

As you can see, the question works better than the statement, unless you use the passive.

None of these are really common.

I hear "She has yet to do something/anything worthwhile." (So far, she hasn't done anything worthwhile.)

例2:Police were yet to confirm whether..

解释:

"To be yet to" means that they are working on confirming the details, but they haven't yet.

Here's an example:

"I have yet to meet another person who has read the book by John Smith." 

It almost implies that I'm actually looking for someone who has read the book, but I just can't find anyone. 

It could also be written in these ways:

"I have yet to meet anyone who has read the book by John Smith."
"I haven't yet met anyone who has read the book..."
"I still haven't met anyone who has read the book..."

I hope that I haven't confused you more!

从:http://forum.wordreference.com/showthread.php?t=984372&langid=22

 

 

转载于:https://my.oschina.net/uniquejava/blog/204169

<think>我们正在处理一个Git错误:"You are on a branch yet to be born"。这个错误通常发生在远程仓库(服务器上的裸仓库)与本地仓库的状态不一致时。根据引用[1],一种解决方法是修改服务器上裸仓库的post-receive钩子,添加特定内容。但更常见的情况是本地仓库试图推送到一个远程仓库中不存在的分支,或者远程仓库的分支处于一种未初始化的状态。 根据经验,这个错误通常发生在以下情况: 1. 你刚刚在远程仓库创建了一个新的空仓库(没有任何提交和分支)。 2. 在本地,你初始化了一个仓库,并做了一些提交,然后尝试推送到远程仓库的一个分支(比如master或main),但远程仓库还没有这个分支(因为没有任何提交,所以分支实际上不存在)。 错误信息完整形式可能是: remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: is denied, because it will make the index and work tree inconsistent remote: with what you pushed, and will require 'git reset --hard' to match remote: the work tree to HEAD. remote: remote: You can set the 'receive.denyCurrentBranch' configuration variable remote: to 'ignore' or 'warn' in the remote repository to allow pushing into remote: its current branch; however, this is not recommended unless you remote: arranged to update its work tree in some other way. remote: remote: To squelch this message and still keep the default behaviour, set remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To <remote-repo-url> ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '<remote-repo-url>' 但是,我们遇到的错误是“You are on a branch yet to be born”,这通常是因为远程仓库是一个裸仓库(bare repository)吗?实际上,如果远程仓库是裸仓库,那么它不应该有工作目录,也就不会出现“refusing to update checked out branch”的错误。所以,这里可能的情况是: 引用[1]提到的问题可能是:远程仓库不是裸仓库,并且当前分支(比如master)被检出(checked out),而Git默认不允许推送到非裸仓库的当前分支,因为这会导致工作目录和索引不一致。 然而,错误信息“You are on a branch yet to be born”则更具体地指向:你试图推送到一个远程分支,但这个分支在远程仓库中还不存在(即还没有任何提交),而且远程仓库的当前分支就是这个尚未诞生的分支。 解决方案: 1. 确保远程仓库是一个裸仓库(bare repository)。如果不是,请将其转换为裸仓库,或者在远程仓库上设置`receive.denyCurrentBranch`为`ignore`(不推荐,因为可能导致不一致)。 2. 如果远程仓库是空的(没有任何提交),那么它还没有任何分支。在本地,我们通常会在第一次推送时使用`-u`选项,并指定分支名。但是,由于远程分支不存在,我们需要在推送时创建它。 3. 常见的第一次推送命令是: ```bash git push -u origin master ``` 或者,如果你使用的主分支名是`main`: ```bash git push -u origin main ``` 4. 如果遇到上述错误,可以尝试在远程仓库中创建一个初始提交(如果远程仓库不是裸仓库并且你有访问权限的话)。但通常,我们更希望保持远程仓库为裸仓库。 5. 另一种方法:在本地仓库中,确保你有一个初始提交。然后,尝试强制推送: ```bash git push --set-upstream origin master --force ``` 但注意,强制推送在多人协作中需谨慎。 6. 根据引用[1]的提示,修改远程仓库的`post-receive`钩子。具体来说,在远程仓库的`hooks`目录下,找到(或创建)`post-receive`文件,并添加以下内容: ```bash #!/bin/sh git checkout -f ``` 然后给这个文件可执行权限。但是,这种方法只适用于非裸仓库,而通常远程仓库应该是裸仓库,所以不推荐。 7. 更推荐的做法:将远程仓库设置为裸仓库。如果远程仓库是你自己搭建的,你可以重新初始化它为裸仓库: ```bash # 在远程服务器上 cd /path/to/repo.git git config --bool core.bare true ``` 或者,在初始化远程仓库时使用`--bare`选项: ```bash git init --bare myrepo.git ``` 8. 如果远程仓库已经是裸仓库,那么出现这个错误可能是因为远程仓库的HEAD指向了一个不存在的分支(比如,它指向了master,但master分支还没有任何提交)。我们可以通过登录远程服务器,进入裸仓库目录,修改HEAD文件的内容,指向一个存在的分支。例如,如果远程仓库期望的分支是main,那么可以执行: ```bash echo ref: refs/heads/main > HEAD ``` 总结步骤: 步骤1:检查远程仓库是否是裸仓库。如果不是,将其设置为裸仓库(推荐)或者设置`receive.denyCurrentBranch`为`ignore`(不推荐,仅当非裸仓库且你知道后果时使用)。 步骤2:在远程仓库中,确保HEAD指向一个有效的分支(即使这个分支还没有提交,但通常HEAD会指向一个默认分支名,如master或main)。如果指向的分支不存在,那么需要修改HEAD文件。 步骤3:在本地,确保你有初始提交,然后尝试推送: ```bash git push origin master:master ``` 或者,如果远程仓库期望的分支名是main: ```bash git push origin master:main ``` 步骤4:如果步骤3失败,可以尝试强制推送(注意:仅当你是唯一使用该仓库的人,并且确定可以覆盖时): ```bash git push -f origin master:master ``` 步骤5:如果问题仍然存在,检查远程仓库的权限,确保你有推送权限。 注意:在多人协作的项目中,强制推送可能会覆盖他人的提交,因此要谨慎使用。 下面,我们根据上述分析,给出一个具体的解决步骤。 具体解决步骤: 1. 首先,确认远程仓库的状态。如果你有访问远程仓库的权限,登录到远程服务器,进入仓库目录,检查是否是裸仓库: ```bash git rev-parse --is-bare-repository ``` 如果返回`true`,则是裸仓库;如果返回`false`,则不是。 2. 如果不是裸仓库,你有两个选择: a) 将其转换为裸仓库(推荐): 在远程仓库目录下执行: ```bash git config --bool core.bare true mv .git/* ./ rm -rf .git # 注意:这个命令会删除.git目录,确保当前目录已经包含了.git目录下的所有文件 ``` 或者,更安全的方法是重新克隆一个裸仓库。 b) 或者,设置`receive.denyCurrentBranch`为`ignore`(不推荐): ```bash git config receive.denyCurrentBranch ignore ``` 3. 如果是裸仓库,检查HEAD文件的内容: ```bash cat HEAD ``` 它应该类似于:`ref: refs/heads/master` 或 `ref: refs/heads/main`。确保这个分支名是你本地想要推送的分支名。如果不匹配,你可以修改它: ```bash echo "ref: refs/heads/<branch-name>" > HEAD ``` 其中`<branch-name>`是你想要的分支名(例如master或main)。 4. 在本地仓库,添加一个初始提交(如果还没有的话): ```bash git add . git commit -m "Initial commit" ``` 5. 然后,尝试推送: ```bash git push -u origin <local-branch-name>:<remote-branch-name> ``` 例如,将本地的master分支推送到远程的master分支: ```bash git push -u origin master:master ``` 6. 如果还是不行,可以尝试强制推送(慎用): ```bash git push -f origin master:master ``` 7. 如果问题依旧,请检查网络连接、远程仓库地址是否正确,以及是否有推送权限。 注意:在第一次推送时,如果远程仓库是空的,通常我们只需要执行`git push -u origin master`即可。但如果你遇到这个特定的错误,按照上述步骤操作。 根据引用[2],我们还可以使用`git cherry-pick`来合并指定的提交,但这与当前问题关系不大。 因此,针对这个错误,我们主要从远程仓库的设置和本地推送操作入手。 相关问题: 1. 如何初始化一个远程Git仓库? 2. 如何将非裸仓库转换为裸仓库? 3. Git推送时遇到权限问题如何解决? 4. 如何修改Git远程仓库的HEAD引用? 5. 为什么Git默认不允许推送到非裸仓库的当前分支?</think>### Git 错误 "You are on a branch yet to be born" 分析与解决 此错误通常发生在以下场景: **远程仓库是空仓库**(尚未包含任何提交或分支),而您尝试将本地分支推送到远程时,Git 无法在远程找到对应的目标分支。本质是本地与远程分支状态不一致导致的同步冲突。 --- #### 解决方法 ##### ✅ 方案 1:强制创建远程分支(推荐) 在本地执行以下命令,强制将本地分支推送到远程并创建同名分支: ```bash git push --set-upstream origin <本地分支名> --force # 示例:若本地分支为 main git push -u origin main -f ``` - `-f / --force`:强制覆盖远程状态 - `-u`:建立本地与远程分支的追踪关系 - 适用于**全新空仓库**的首次推送[^1] ##### ✅ 方案 2:重置远程 HEAD 引用 如果方案 1 无效,可能是远程仓库的 `HEAD` 引用损坏: 1. 登录远程服务器,进入仓库目录 2. 修正 `HEAD` 文件指向正确分支: ```bash # 假设目标分支为 main echo "ref: refs/heads/main" > HEAD ``` 3. 本地重新推送: ```bash git push -u origin main ``` ##### ⚠️ 方案 3:修改远程钩子(备用) 在远程仓库的 `hooks/post-receive` 中添加(需服务器权限): ```bash #!/bin/sh git checkout -f # 强制检出分支 ``` 赋予执行权限: ```bash chmod +x hooks/post-receive ``` > 注意:此方案可能引发副作用,仅在前两种方案无效时使用[^1] --- #### 根本原因 - 远程仓库初始化后未生成有效分支(如 `git init --bare` 创建的裸仓库) - 本地与远程的 `HEAD` 引用指向不一致的分支 - 远程仓库缺少首次提交,分支未被实际创建 --- #### 预防措施 1. **首次推送空仓库**时显式指定分支: ```bash git push -u origin main:main --force ``` 2. 创建远程仓库时添加初始提交: ```bash git init --bare && git commit --allow-empty -m "Initial commit" ``` 3. 检查远程仓库状态: ```bash ssh user@server "git -C /path/to/repo symbolic-ref HEAD" ``` > 提示:现代 Git 默认分支名已从 `master` 改为 `main`,操作时需注意分支名称匹配。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值