当运行git状态时,我得到以下信息
Your branch is ahead of 'origin/master' by 3 commits.
我在其他一些帖子上读过,解决这个问题的方法是运行git拉—rebase,但rebase到底是什么,我会丢失数据吗,还是这是与主同步的简单方法?
当运行git状态时,我得到以下信息
Your branch is ahead of 'origin/master' by 3 commits.
我在其他一些帖子上读过,解决这个问题的方法是运行git拉—rebase,但rebase到底是什么,我会丢失数据吗,还是这是与主同步的简单方法?
当前回答
Git重置-硬源/主
使用这个命令
其他回答
有一次我在Bitbucket上合并了一个pull请求,我就遇到了这种情况。
我只需要做:
git fetch
我的问题解决了。我希望这对你有帮助!!
您会收到这条消息,因为您在本地主服务器中进行了更改,而没有将它们推到远程。你有几种方法来“解决”它,这通常取决于你的工作流是什么样子的:
在一个好的工作流程中,master的远程副本应该是好的,而master的本地副本只是远程副本的副本。使用此工作流,您将永远不会再次收到此消息。 如果你以另一种方式工作,你的局部变化应该被推动 然后git push origin,假设origin是你的遥控器 如果您的本地更改是坏的,那么只需删除它们或重置您的 本地主到远程git重置的状态——硬源/主
使用这4个简单的命令
步骤1:git checkout <branch_name>
这是很明显的分支。
步骤2:git拉-s递归-X their
获取远程分支变更,并在发生冲突时替换它们的变更。 在这里,如果你使用git状态,你会得到这样的东西,你的分支领先'origin/master' 3次提交。
步骤3:git reset——hard origin/<branch_name> . zip
步骤4:git取回
硬重置你的分支。
享受。
这条来自git的消息意味着您已经在本地repo中进行了三次提交,并且还没有将它们发布到主存储库。要运行的命令是git push{本地分支名称}{远程分支名称}。
The command git pull (and git pull --rebase) are for the other situation when there are commit on the remote repo that you don't have in your local repo. The --rebase option means that git will move your local commit aside, synchronise with the remote repo, and then try to apply your three commit from the new state. It may fail if there is conflict, but then you'll be prompted to resolve them. You can also abort the rebase if you don't know how to resolve the conflicts by using git rebase --abort and you'll get back to the state before running git pull --rebase.
我在Bitbucket上合并了一个pull请求后遇到了这个问题。
不得不做
git fetch
就是这样。