我如何快速转发分支机构,当我git fetch上网期间编辑时,现在我处于离线状态,并希望快速前进到我之前提取的状态.
例如,我离线并执行以下操作:
$ git checkout develop
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 37 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Run Code Online (Sandbox Code Playgroud)
在尝试使用时,git pull我得到:
$ git pull
ssh: Could not resolve hostname <hostname>: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
在这种情况下我需要使用什么命令?
因为git pull基本上是git fetch+ git merge你已经做过fetch而且离线时不能再做,你只需要这样做git merge origin/develop.
或者git reset --hard origin/develop,即使没有快进,你也可以做到.
编辑:更多选项.另一种方法是git branch -f develop origin/develop在切换到它之前做- 你不能改变当前分支,但只要它不是最新的,你就可以将任何分支"更新"到任何状态.对于当前分支,您必须使用git reset.